A while ago, I did a webinar for TypeMock about unit testing legacy code. It’s about why we want to unit test legacy code, the advantages and disadvantages, and it includes some minor live coding using TypeMock’s Isolator tool. You can watch it here: I hope you like it. Let me know what you think!
Continuing this series on CQRS and ES in .NET, we’re now going to focus on Event Handlers. I previously covered: CQRS/ES The Command The Command Handler The Repository The Domain Object If you haven’t read them, I advise you to to so first. Read them in order, because they build upon each other. If you’re already familiar with CQRS and Event Sourcing, you can skip the first one. As you might recall, when we modify an aggregate, it stores pending
If you haven’t read the previous posts in this series, you might want to check out: CQRS/ES The Command The Command Handler The Repository In this post, I will look at the Domain Object. So far, we know we can create a Command, give it to the Command Handler, who will use the Repository to retrieve a Domain Object and call the necessary methods on it. After that, the Command Handler will tell the Repository to save the object. Let’s
So far, we’ve covered the CQRS/ES pattern, the Command object, and the Command Handler object. In our last post, we saw that the Command Handler needs a repository to retrieve an object and save it after changes have been made. In this post, I will go into the Repository. The Interface The Repository will be responsible for finding an aggregate and saving it. So our public interface is simple: Let’s take this apart. First, it’s a generic interface, but we’ll
In my previous post, I explained how the Command in (our) CQRS implementation is just a DTO. This means we need to send it somewhere. Meet the CommandHandler. First, let’s define the interface. This will come in handy when we want to use dependency injection later. In my case, I injected the interface into my ASP.NET controllers so I could easily unit test them. The interface is simple: There’s not much to it, except for the fact that we only
Let’s start with the C in CQRS. As you know by now, the C is for “Command.” In our implementation of CQRS/ES, a command will be a basic DTO object. Later, we’ll see that CommandHandlers will take such a command and perform the necessary calls to domain objects. But let’s start simple. As stated, a command will be a simple DTO object, without any special logic. In my case, without any logic at all, except for a constructor. The name
CQRS (command and query responsibility segregation) and ES (event sourcing) are two patterns that are easily explained, but not so easily implemented. The patterns are gaining traction and often come together. But many developers have been trained in a classic CRUD way, and don’t always know where to begin. In this series, I’ll not only cover CQRS/ES abstractly, but I’ll provide real code examples to show you it’s really not very difficult. This first post will, however, focus on the
Note: I originally wrote this for SubMain. You can read the original here. Depending on your age and experience as a .NET developer, you might or might not be familiar with the technology known as Windows Forms. Windows Forms, or WinForms, was introduced together with .NET 1.0 in 2002. It was the first desktop UI technology for .NET. We’re now 16 (!) years later, and WinForms runs on the latest version of the .NET Framework (currently 4.7.2) and .NET Core
Note: I originally wrote this for SubMain. You can find the original here. In one of my previous posts, I wrote about the .NET build configuration system. I mentioned the app.config file, but didn’t really dive into it. So let’s take a closer look at this file now. When you create a (non-web) .NET Framework application in Visual Studio, an app.config file is added to your project. When you create a class library or a .NET Core project, such a file
I’ve been programming for more than 10 years now, and only recently heard about Primitive Obsession. I’ve been guilty of this now and then. But I’ve also written/extended a library that tackles exactly that. Primitive Obsession is the use of primitive data types (i.e. strings, integers, doubles, etc.) for simple tasks, instead of using small objects. Examples are currency, phone numbers, postal codes, etc. Why would you not use primitive types for this? Surely a simple concept like a postal