Plainionist Tales of a software craftsman's journey

Implementing Clean Architecture - To use or not to use MediatR?

Circles of Clean Architecture and logo of MediatR

MediatR is a popular library in .NET used to decouple components. In Clean Architecture we aim to keep the core of the application as independent as possible from such “details” like third-party libraries and frameworks.

Nevertheless, I have recently read quite some articles and watched some great videos about using MediatR in Clean Architecture based projects.

But doesn’t the usage of MediatR in Clean Architecture break the Dependency Rule?

More ...

Book Review: BDD in Action

If you have at least some professional software engineering experience you probably have heard of BDD and probability is high that you just think of Gherkin and GIVEN-WHEN-THEN when you think of BDD. But actually BDD is much, much more as this book illustrates:

Book: BDD in Action

BDD in Action

More ...

Book Review: Atomic Habits

Do you have habits you consider as “bad” and you want to get rid of?

Do you have goals you want to achieve but your are not making big progress yet?

If you want better results, then forget about setting goals. Focus on your system instead.

– James Clear, Atomic Habits

More ...

Dynamic Decorators

The decorator pattern is a powerful tool to apply “aspects” or cross cutting concerns such as logging or caching to a type without breaking the Single Responsibility Principle (SRP).

But sometimes creating and maintaining decorators with bigger interfaces or a bigger number of decorated types becomes a problem. Dynamic proxies can be a solution to this.

More ...

Bulletproof thread collaboration?

When it comes to concurrency my main axiom is: concurrency issues like race-conditions have to be avoided by design because detecting those via testing is pretty hard and actually close to impossible.

So how can we design the collaboration of concurrently executed parts of a software system in a way that classic concurrency issues are avoided?

More ...

Automating dependency governance in .NET

Every software project of some reasonable size needs some structure to manage complexity and to ensure that it fits into every developers head.

Every structure also implies some rules on which code should go where and which dependencies are allowed, for example

  • dependencies between architectural layers are only allowed in one direction
  • avoid coupling between individual components or features
  • code creating “painful dependencies” should kept outside of the business logic assemblies

But how to ensure that those rules are followed in the daily business of a software project?

More ...

Book Review: Code That Fits in Your Head

Obviously, you must write code such that the resulting software works as desired. That’s no longer the main problem of software engineering. The challenge is to organize it so that it fits in your brain. Code must be humane. – Mark Seemann, Code that fits in your head

The goal of software design is to create chunks or slices that fit into a human mind. The software keeps growing but the human mind maxes out, so we have to keep chunking and slicing differently if we want to keep making changes. – Kent Beck

You should aim for an architecture of your code base so that regardless of where you look, the code fits in your head. At a high level, there’s seven or fewer things going on. In the low-level code, there’s at most seven tings you have to keep track of. At the intermediary level, this still holds. – Mark Seemann, Code that fits in your head

Book: Code That Fits in Your Head

Code That Fits in Your Head

More ...

Making The Invalid Unrepresentable - Part 2

After having created this video

on how to “make invalid cases unrepresentable” when implementing the domain model in object oriented programming languages, I realized we could actually take it one step further.

More ...

How I made my finally block not being called (.Net)

In .Net the source code of a finally block is always called, right? Even if there is a return statement or an exception is thrown in the try block, correct? I mean, this is the reason why we use try-finally in the first place.

Well, I got into a case where the code of the finally block was not called …

More ...

Assumptions aren't that bad in source code if ...

Design-by-Contract is not only an easy way to find bugs earlier, it is also a great tactic to improve your code quality. With Design-by-Contract we can document expectations and assumptions crystal clear in the source code itself and so improve changeability and maintainability!

How this works I explain in this video:

More ...

Implementing Clean Architecture - Case Study: Sending e-mails

During my day job we recently did a code review of a small feature of an application which aims to follow the principles of Clean Architecture. At a first glance separation of concerns as well as basic principles of Clean Architecture were followed. But a closer look revealed that some dependencies did not follow the Dependency Rule, specifically there were dependencies from adapters layer to the frameworks layer.

During our design discussions which followed this observation I realized that this example would perfectly serve for a case study on how to design a feature in Clean Architecture in detail.

So here we go …

More ...

Don't comment it! Refactor it!

Do you think Clean Code should be very well documented? Do you think code comments should help the reader to understand what the code is doing? Or do you rather prefer DRY principle with respect to code comments?

Here is another video for you …

More ...

This is how you should start with Clean Code ...

As a software craftsman Clean Code is one of my key interests so I started a YouTube channel to provide practical coding tutorials on how to apply Clean Code principles.

In my first video I demonstrate that Clean Code does not only start when you write a new component or add a new feature to some existing code base. Instead you can start applying Clean Code principles and especially the Boy Scout Rule already while reading code.

More to come! Stay tuned!

More ...

Book Review: Domain Modeling Made Functional

Unless you are not completely new to our profession I am pretty sure you already heard about “Domain Driven Design” (DDD). But maybe you think that DDD requires quite some effort which is only worth it in big software projects and that it has to be done in the beginning of a project to be effective?

This is not necessarily true …

Here is a book which nicely demonstrates that DDD and Functional Programming (F#) are two great tools to tackle software complexity in any software project, even in a small pet project:

Book: Domain Modeling Made Functional: Tackle Software Complexity with Domain-Driven Design and F#

Domain Modeling Made Functional: Tackle Software Complexity with Domain-Driven Design and F#

More ...

Book Review: The Software Craftsman: Professionalism, Pragmatism, Pride

Yes, of course. Who has time? Who has time? But then if we never take time, how can we have time? – Merovingian, Matrix Reloaded, 2003

If you think you don’t have time, even not to learn and practice, here is the one book you need to take time for:

Book: The Software Craftsman: Professionalism, Pragmatism, Pride

The Software Craftsman: Professionalism, Pragmatism, Pride

More ...