Monthly Archives: December 2014

Don’t use Ids in your domain entities!

How often do you see code like this in your domain model?

public void Ship(int orderId, int customerId, string address)


    Shipment shipment = _existingShipments.Single(x => x.OrderId == orderId);

    if (shipment.CustomerId == customerId)


        // Do something



Seems pretty good, doesn’t it? Well, it doesn’t. I’ve already pointed using Ids in domain entities as a bad practice, but I see developers – even sophisticated ones – write such code over and over again, so this topic definitely deserves a separate article.

More about Ids in domain entities →

I/O Threads Explained

Microsoft has released async/await feature in .Net 4.5. It’s a really great stuff as it significantly simplifies one of the most painful areas – asynchronous programming. Before that, Task Parallel Library (TPL) and Parallel LINQ (PLINQ) were released in .Net 4.0. They address problems with parallel programming – another painful area in .Net.

I often see programmers struggling with a question when to use each of these features. Let’s step back and recall what does it actually mean to be asynchronous or parallel.

I/O threads →