Let’s talk about modeling of relationships, including the dreaded many-to-many relationships, in a DDD way.| Enterprise Craftsmanship
Does the primitive obsession anti-pattern apply to collections? In other words, should you introduce a custom class for a collection?| Enterprise Craftsmanship
Today, we’ll discuss a question that relates to my Unit Testing book: how to assert the state of the database?| Enterprise Craftsmanship
This article is inspired by a tweet that I thought would be a good topic for discussion: should you abstract your database?| Enterprise Craftsmanship
Today, we’ll discuss an interesting use case of handling nulls in value objects. Should you put null inside the value objects themselves or decorate those value objects using the nullable reference type notation (? or Maybe)?| Enterprise Craftsmanship
Are static methods good or bad? Over the course of my career I did a full circle on this topic. In this article, I’ll try to describe this evolution and the reasoning behind it.| Enterprise Craftsmanship
UPDATE 5/13/2021: the course has been published, check it now here: Validation and DDD. I’m working on a new Pluralsight course on the topic of validation and DDD, with the help of the FluentValidation library and .NET data annotations (attributes). So expect a couple of posts about validation in the near future.| Enterprise Craftsmanship
Today, we’ll talk about the new C# 9 feature, Records, and whether or not they can be used as DDD value objects.| Enterprise Craftsmanship
How to unit test an abstract class? Or a whole class hierarchy that depends on that abstract class? Let’s see.| Enterprise Craftsmanship
In this post, we’ll make a deep dive into the DRY and DAMP principles and will talk about the false dichotomy around them.| Enterprise Craftsmanship
The use of mocks in unit testing is a controversial topic (maybe less so now than several years ago). I remember how, throughout my programming career, I went from mocking almost every dependency, to the "no-mocks" policy, and then to "only mock external dependencies". None of this practices are good enough. In this article, I’ll show you which dependencies to mock, and which to use as is in your tests.| Enterprise Craftsmanship
In this post, we’ll talk about whether or not you should use assertion messages in tests.| Enterprise Craftsmanship
There’s an interesting guideline I’ve been meaning to write about for a long time. I call it Storing information in its highest form.| Enterprise Craftsmanship
Let’s talk about when to use which collection type and why.| Enterprise Craftsmanship
Today, we’ll discuss the following guideline: you should use the most generic types possible for arguments and the most specific types possible for return values.| Enterprise Craftsmanship
My new online training course about Encapsulating EF Core Usage went live.| Enterprise Craftsmanship
Today, we’ll talk about an important question: how does the application database fit into the concept of Always-Valid Domain Model? In other words, is the database part of the always-valid boundary or should you consider it an external system and validate all data coming from it?| Enterprise Craftsmanship
There’s an interesting controversy between two DDD topics: the Specification pattern and the Always-Valid domain model.| Enterprise Craftsmanship
My new online training course about Validation and DDD went live.| Enterprise Craftsmanship
Today, we’ll discuss how to best handle unique constraint violations.| Enterprise Craftsmanship
I’m continuing the topic of domain model purity. Last time, we talked about domain model purity in the context of getting the current date and time. Today, we’ll discuss it with regards to lazy loading.| Enterprise Craftsmanship
I’m continuing the topic of domain model purity. This time, we’ll look at it with regards to getting the current date and time. By the way, be sure to subscribe to my email list. Not all discussions fit the format of a blog post (including some shorter takes on the topic of domain model purity vs completeness). I send those out as emails instead.| Enterprise Craftsmanship
I’ve been meaning to write this article for a long time and, finally, here it is: the topic of domain model purity versus domain model completeness.| Enterprise Craftsmanship
This post is about where to put the equality comparison logic: under the test or production code.| Enterprise Craftsmanship
Need to change validation rules but have pre-existing data that doesn’t follow the new rules? In this post, we’ll talk about how to do that properly.| Enterprise Craftsmanship
In this article, we’ll review the types of unit testing dependencies. This is more of a reference article, to which I’ll be referring in future posts. Still, this topic is important for establishing the common vocabulary.| Enterprise Craftsmanship
My new online training course DDD and EF Core: Preserving Encapsulation went live.| Enterprise Craftsmanship
This article is about 3 things that can make or break any software project.| Enterprise Craftsmanship
In this post, we’ll discuss an interesting question about whether the concepts of Entity and Value Object are the same.| Enterprise Craftsmanship
Combining bulk operations with Domain-Driven Design is a tough problem. In this article, we’ll look at why that is so and discuss ways to marry the two.| Enterprise Craftsmanship
This is a continuation of the article series about some more advanced error handling techniques.| Enterprise Craftsmanship
This post describes some (more) advanced error handling techniques. I’ll probably do a series because this topic is large and there’s quite a few things that need to be cleared out, but we’ll see.| Enterprise Craftsmanship
Giving your tests expressive names is important. Proper naming helps understand what the test verifies and how the underlying system behaves. In this post, we’ll take a look at a popular, yet inferior naming convention and see how it can be improved.| Enterprise Craftsmanship
I’m writing a book called Unit Testing: Principles, Patterns and Practices.| Enterprise Craftsmanship
This post describes a common problem: how to deal with multiple domain events if raising of one of them must negate the others.| Enterprise Craftsmanship
In this article, I’d like to discuss one particular aspect of exception handling relevant to CQRS and the decorator pattern.| Enterprise Craftsmanship
There’s a question that I didn’t cover in the course and that was raised at least twice since then: when to validate commands in CQRS?| Enterprise Craftsmanship
I published an online course about CQRS a couple months ago, and since then I realized that there are some topics I didn’t put enough emphasize on in that course, or didn’t cover at all. In the next several blog posts, I’m going to fill this gap.| Enterprise Craftsmanship
This article is a response to a reader’s question. The question posed an interesting problem that I think will be interesting to a wider audience.| Enterprise Craftsmanship
This is an article about how two DDD patterns contradict each other.| Enterprise Craftsmanship
My new online training course CQRS in Practice went live.| Enterprise Craftsmanship
In this article, we’ll talk about ORMs and lazy loading.| Enterprise Craftsmanship
Today, we’ll discuss the difference between identity in the DDD sense and database primary keys. We often mix the two together but are they really the same thing?| Enterprise Craftsmanship
UPDATE 3/5/2020: I’ve expanded on this article and updated its content for EF Core 3.1 in my new Pluralsight course DDD and EF Core: Preserving Encapsulation. That was probably a long wait for those of you who follow my blog. But, better late than never, so here it is: another comparison of Entity Framework and NHibernate, in which I bash EF Core and present it as an unbiased review. Just kidding, I do try to be unbiased here to the best of my skills.| Enterprise Craftsmanship
Today’s article is an answer to a reader’s question about the use of Value Objects to represent the identity of an entity.| Enterprise Craftsmanship
This is the final post in my series about unit testing anti-patterns. This one is about non-determinism in tests.| Enterprise Craftsmanship
I’m continuing my unit testing anti-patterns article series. Today, we will talk about overriding methods in classes-dependencies.| Enterprise Craftsmanship
My new training course Domain-Driven Design: Working with Legacy Projects went live.| Enterprise Craftsmanship
Good news everyone! NHibernate 5.1 is released with the support of .NET Core 2.0 and .NET Standard 2.0.| Enterprise Craftsmanship
This is another post from my unit testing anti-patterns article series. Today, we will talk about code pollution.| Enterprise Craftsmanship
I haven’t done one of these for a while. This post is a review of a code submitted by a reader.| Enterprise Craftsmanship
I was asked a question recently which I find quite interesting. It is actually a part of a code review request (which I’ll cover next week) but I decided to elevate it to its own blog post.| Enterprise Craftsmanship
I’m continuing the series about unit testing anti-patterns I started a couple months ago. This article is about leaking domain knowledge to tests.| Enterprise Craftsmanship
To TDD or not to TDD? Is this question even relevant or maybe it’s enough to just write tests, no matter before the code or afterward? Let’s see.| Enterprise Craftsmanship
This news went mostly unnoticed but that’s actually a big one, at least for those of us who uses NHibernate as their primary ORM: NHibernate 5 now supports async IO bound operations.| Enterprise Craftsmanship
I got a suggestion recently about using .NET structs to represent DDD Value Objects to which I repeated what I’ve been saying and writing for several years now: structs are not a good choice for DDD Value Objects. But then I realized that I never actually dove into the details of why it is so. So here it is, the blog post where we’ll talk about using .NET Value Types (structs) as DDD Value Objects and what effect it has on the domain model, performance, and mapping the model to the databa...| Enterprise Craftsmanship
My new training course Refactoring from Anemic Domain Model Towards a Rich One went live.| Enterprise Craftsmanship
Last time, we talked about making private methods public in order to enable unit testing. It’s not the only way people expose implementation details to the outside world for unit testing purposes, though. Today, we’ll look at a similar anti-pattern: exposing private state.| Enterprise Craftsmanship
I’m starting a new series about unit testing anti-patterns. This post is the first article in that series. When it comes to unit testing, one of the most commonly asked questions is: how to test a private method?| Enterprise Craftsmanship
Today, I’d like to write about a simple and reliable way to implement domain events.| Enterprise Craftsmanship
In this post, I’m answering a reader’s question about how to combine an optimistic locking and automatic retry.| Enterprise Craftsmanship
This post is about a better implementation of Value Object.| Enterprise Craftsmanship
In this post, I’d like to talk about what I think is one of the most damaging attitudes a company or a person can have in the field of software development: short-sighted perspective.| Enterprise Craftsmanship
I’m back to the regular posting schedule. No more game development, at least for now.| Enterprise Craftsmanship
Final part of my story about game development. First part, second part. Client side load balancing In the previous post, I wrote about performance optimizations. We figured that a single 1 CPU server in Azure could handle up to 600 simultaneous users spread across 3 game scenes (also known as game arenas; each scene takes one OS process). Now we needed a mechanism for distributing the players across multiple servers and game scenes in those servers.| Enterprise Craftsmanship
Part 2 of my story. You can read the first part here. Working on the tank design I wrapped up the previous post by saying that we decided to change the game idea from robots to tanks. We refined our vision of the game. There were going to be multiple tank levels to introduce a sense of progression. When starting up, you’d have a tank with the least amount of health (hit point, HP) and fire power, and proceed to a tank of the highest level.| Enterprise Craftsmanship
If you read this blog regularly, you know that I usually write about DDD, functional programming, and enterprise software development best practices in general. These are the techniques I enjoy talking about, as well as applying them in my own projects. However, there was another field I always wanted to try myself in. That is game development. The ability to write my own games was the reason why I started learning to program in the first place. And I believe many programmers had this motivat...| Enterprise Craftsmanship
This post is about how to work with information that is spread across multiple microservices.| Enterprise Craftsmanship
My new course Specification Pattern in C# for Pluralsight went live. Specification Pattern in C# This is a fairly short course (about an hour) which will teach you everything about the Specification Pattern and how to apply it in C# in combination with modern ORMs. From this course, you will learn: Use cases for the Specification Pattern. Common pitfalls people run into when implementing it.| Enterprise Craftsmanship
In this post, we’ll discuss Value Objects. Specifically, when to introduce them into your code.| Enterprise Craftsmanship
In this post, I’d like to talk about naming and Ubiquitous Language.| Enterprise Craftsmanship
This is the second code review session where I showcase a real-world code example. If you want to learn more about this new format, check out this post. You can also request a review yourself. To do that, use the form on this page. Code review: Fabric class The full source code of this one is rather large for a single blog post, so I decided to pick the most interesting portions of it - those I think could be improved.| Enterprise Craftsmanship
I apologize to everyone who’s waiting for my response to their code review requests. I was busy dealing with some personal stuff the last couple of weeks. Moving forward, I’m going to maintain a one post a week schedule where "regular" articles would take turns with code reviews. This article is a regular one, so the one next week would be a code review. Today, I’d like to talk about IEnumerable and IReadOnlyList collection interfaces. We’ll discuss which of them is preferable and in ...| Enterprise Craftsmanship
In this post, we will explore a common design problem: implementing a Main Something property. There’s an equally common solution to this problem which is sub-optimal in most cases.| Enterprise Craftsmanship
This is the first code review where I showcase some real-world code example and nitpick suggest improvements in it. If you want to learn more about this new format, check out this post. You can also request a review yourself. To do that, use the form on this page. Code review: User Controller and error handling The code in question is a UserController class with this Create method: publicIActionResult Create([FromBody] UserCreateModeluser)| Enterprise Craftsmanship
When I started this blog, I had one idea in mind: create some sort of repository of programming principles and practices so that I myself and other people would have an easier time navigating around them. That’s a nice goal to aim for but I noticed that when it comes to the actual process of writing code, having such a repository is often not enough.| Enterprise Craftsmanship
This topic is partly covered in my Applying Functional Principles in C# Pluralsight course, Module 2. Here, I’d like to elaborate on how temporal coupling and immutability are related to each other. Temporal coupling Temporal coupling is coupling that occurs when there are two or more members of a class that need to be invoked in a particular order. A common example is the following: var calculator = new PriceCalculator(); calculator.| Enterprise Craftsmanship
This is a continuation of the topic of error handling. We’ll discuss what an exceptional situation in code actually is and see some examples of it.| Enterprise Craftsmanship
In this post, we’ll look at some practical examples of error handling. We will see whether it is better to use exceptions or the Result class to deal with errors.| Enterprise Craftsmanship
Today’s topic is about interfaces for repositories. Should you introduce them? Or maybe it’s better to use repositories as is? Let’s see.| Enterprise Craftsmanship
This post is about some bad practices in using automappers.| Enterprise Craftsmanship
Today, I’d like to talk about the (sometimes subtle) difference between 4xx and 5xx response codes when programming a RESTful API. I’ll try to show when to return what code (400 or 500) and introduce a simple way to implement this logic on the server side.| Enterprise Craftsmanship
This topic might seem trivial, especially if you look at all other articles that have beaten it to death already. But I would still like to make a couple of important points here. So, how long should a single method be?| Enterprise Craftsmanship
I already did this thing last year, so I thought I would do it again. Below is an overview of the articles I posted this year and a little bit of reflection on them. Retrospective It’s interesting to look at the progression of blogging topics throughout the whole year. They mostly followed the Pluralsight courses I was working on at the time. While writing a course, I remember finding lots of ideas that were worth extracting into a separate self-contained blog post.| Enterprise Craftsmanship
Today’s topic is about custom exception types. That is whether or not you should write your own exception types to throw in different situations.| Enterprise Craftsmanship
In this post, I want to cover the topic of OCP vs YAGNI - contradictions between the Open/Closed Principle and the You aren’t gonna need it one. OCP Let’s start with a refresher for what OCP is. The Open/Closed principle states that: Software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification. It was first introduced by Bertrand Meyer in his canonical Object-Oriented Software Construction book.| Enterprise Craftsmanship
Should you always mock out your database? Or should you include it in the unit/integration testing scope? What about other external systems? This post is based on my Pluralsight course about Pragmatic Unit Testing. Two types of external dependencies When it comes to external dependencies (dependencies outside the process that hosts your application, such as a database, a 3rd party system, etc.), there’s no single guideline regarding how to work with them in tests.| Enterprise Craftsmanship
Today’s topic is gonna be about OOP, FP, and object-relational impedance mismatch. The goal of this article is to show how object-oriented and functional paradigms deal with relational data stores.| Enterprise Craftsmanship
Last week I wrote about when to use mocks. In this post, I’d like to outline a specific guideline which comes into play when you start working with mocks: verifying collaborations at the system edges. This article is based on my recent Pluralsight course about Pragmatic Unit Testing. Verifying collaborations at the system edges The use of mocks goes hand in hand with the style of unit testing which I call collaboration verification.| Enterprise Craftsmanship
My new course Building a Pragmatic Unit Test Suite for Pluralsight went live. Building a Pragmatic Unit Test Suite Unit testing can be applied differently. Like many other things in programming, there are a lot of ways to mess up with it. It’s important to differentiate unit testing techniques that help bring confidence in your code base correctness from techniques that can potentially have a devastating effect on your entire test suite.| Enterprise Craftsmanship
In this post, I’ll show a simple way to get to know if your domain model is properly isolated.| Enterprise Craftsmanship
In this post, we’ll discuss the Law of Demeter in the context of immutability.| Enterprise Craftsmanship
Aggregates carry out many important functions. One of them is maintaining consistency boundaries. In this post, I write about the requirement of global email uniqueness and how it is related to aggregate invariants.| Enterprise Craftsmanship
Validation and DDD can be a tricky combination. How to perform validation in a way that doesn’t lead to domain knowledge leakage?| Enterprise Craftsmanship
In this post, we’ll take a look at domain services: what differs them from application services and when it is preferable to use one in addition to an application service.| Enterprise Craftsmanship
I’ve been using the term "domain model isolation" for a long time already but just recently realized that its meaning might not be as obvious as I thought. In this post, I’ll try to describe what it means to properly isolate your domain model and why it is important.| Enterprise Craftsmanship
In this post, I’ll write about a couple of thoughts regarding what domain logic is and how to distinguish it from other types of logic.| Enterprise Craftsmanship
In this post, we are going to look at what to do if you are not able to treat some concept in your domain as a Value Object and have to make it an Entity. TL;DR: create a nested Value Object inside that Entity and relocate as much domain logic to that Value Object as possible.| Enterprise Craftsmanship
I was reviewing the list of topic ideas lately and found this question in the discussion to my DDD in Practice Pluralsight course. While I answered it - somewhat briefly - in the discussion thread, I think it’s worth a separate detailed blog post. The question itself goes like this: "Can you have a collection of Value Objects abstracted as a Value Object itself?" Or, in other words, can you represent a collection as a Value Object?| Enterprise Craftsmanship
I bet you encounter (and use) the term "implementation detail" a lot. But what it means, exactly? And how to see if something is an implementation detail?| Enterprise Craftsmanship