Separating configuration from your code itself is a good practice. Unfortunately this can quite be
quite complex in itself. In fact it is fair to say that in many cases the use of
DI containers to achieve this can be overkill
for a task that should be rather basic.
Back at the start of 2016 I set about sorting my personal finances out,
inspired by Soft
The book makes a point to consider passive income as a viable solution
to wealth building. The reason for this is simple, software developers
tend to get paid well if working professionally …
Most constants are used to remove magic numbers or variables that lack
context. A classic example would be code littered with the number 7.
What does this refer to exactly? If this was replaced with DaysInWeek or
similar, much clarity is provided. You can determine that code
performing offsets would …
A single domain can grow large when applying Domain Driven Design. It
can become very hard to contain a single model when using ubiquitous
language to model the domain. Classic examples prevalent in many domains
would be Customer or User models. A bounded context allows you to
break down a …
Implementing custom exceptions usually gives a hint as to why you rarely
need custom implementations. They are often nothing more than sub
classes where the only difference is the type name and containing
In this C# example there is a lot of code for nothing. When checking
logs or …
The death of testability and the lack of
make the singleton pattern a relic of times gone by. Rarely have I had a
real need to code a singleton since my first year of university. Most
decisions to use a singleton boil down to scoping issues.
The N+1 problem is when multiple queries are executed against a
persistent store when a reduced amount could serve the same purpose.
This degrades performance, uses more memory and can cause complexity to
be added to the code that processes the results. Most sources of the
problem come from …
There are two types of validation in an application - application
validation and domain validation. This applies whether or not you
practice DDD. One of my mistakes in the past has been confusing or
conflating these two responsibilities at the same time.
Application validation is anything technical or anything …
In some languages such as C++ you must define header interfaces. These
constructs define how a public type is exposed in terms of its public
interface. Other languages take a different route. C# or Java do not
require headers but they are still very much in circulation. This
unfortunately brings …
Duplication in tests can be a good
The same can be said for production code as well in some cases. No. I'm
not going mad. I probably wouldn't believe this if you showed me this
several years ago either. More experience has shown me that loose
coupling is often …
Feature toggles are great for new features or features that are either
enabled or disabled. Branch by Abstraction offers the same benefits as
but the seam to introduce the change is the abstraction itself. Unlike
Feature Toggles, the use of Branch by Abstraction allows a gradual
transition to …
I'm a fan of regular releasing. My background and experience leads me to
release as regularly as possible. There are numerous benefits to regular
releases; limited risk, slicker release processes and the ability to
change as requirements evolve.
The problem with this concept is how can you release when features …
Explicit null checking is a code smell in most cases. It should be
limited where possible, or pushed to the edge of the system. A common
anti pattern I've noticed is the incorrect use of First() in LINQ,
which I have used myself on many occasions in this manner.
The use of randomly generated test data seems like a good thing at first
glance. Having worked with several teams that have used this concept I
generally discourage the practice. Consider a simple method that joins
together two strings. A test using random values may look like this.
After extract method or extract class introducing a value object is one
of the most powerful refactorings available. A value object encapsulates
a value or concept within your domain. While the term is more formally
known from Domain Driven Design, DDD is not a pre-requresite for use.
Introducing a value …