Take a look at this example repository to see the following guidelines and more in action.
Without further introduction, let’s dive in!
Do create a
@NgModule() for each component.
Do place the component module in the same-named folder as the component.
Why? By encapsulating their dependencies in a module, each component can be used and tested independently.
Why? Component dependencies can be replaced and removed without affecting other components.
Why? Components can easily be moved around with their dependencies.
null is probably the worst mistake in programming languages history and has spread in all modern languages since its invention in 1965. Many years later, Tony Hoare, the inventor of the null reference, even apologies for his mistake:
I call it my billion-dollar mistake … My goal was to ensure that all use of references should be absolutely safe, with checking performed automatically by the compiler. But I couldn’t resist the temptation to put in a null reference, simply because it was so easy to implement. …
Aggregates are the heart of your system. They hold domain logic and are responsible for emitting events that will
eventually make your data consistent across multiples data projections and bounded contexts. Because aggregates are so
important, it is crucial to keep them small and easy to understand, but how to do this when the domain gets bigger and
In this article, I will show you a way to reduce complexity from your aggregates and make them scale better.
Before getting started, let review how commands are executed and turned into events.
After receiving the command sent by the user…
A guard clause is a technique derived from the fail-fast method whose purpose is to validate a condition and immediately stop the code execution if the condition is not met by throwing a meaningful error instead of leaving the program to throw a deeper and less meaningful error. Let me show you an example:
In the previous example, the
if block act as a guard clause by protecting the
GetUser method against any null
userName arguments. Like that, we are free to write the rest of the method without having to worry about checking if
userName is null.