What are the benefits of Persistence Ignorance?

Let me explain this with an example. Lets assume your are implementing an application using a classical SQL approach. You open recordsets, change data and commit it. Pseudo code: trx = connection.CreateTransaction(); query = connection.CreateQuery(“Select * from Employee where id = empid”); resultset = query.Run(); resultset.SetValue(“Address_Street”, “Bahnhofstrasse”); resultset.SetValue(“Address_City”, “Zürich”); trx.Commit(); With NHibernate it would look … Read more

Repository Pattern: how to Lazy Load? or, Should I split this Aggregate?

Am I misinterpreting the intent of the Repository pattern? I’m going to say “yeah”, but know that me and every person I’ve worked with has asked the same thing for the same reason… “You’re not thinking 4th dimensionally, Marty”. Let’s simplify it a little and stick with constructors instead of Create methods first: Editor e … Read more

Value Objects in CQRS – where to use

Ok I’ve changed my mind. I have been trying to deal with VOs a bunch lately and after watching this http://www.infoq.com/presentations/Value-Objects-Dan-Bergh-Johnsson it clarified a couple of things for me. Commands and Event are messages (and not objects, objects are data + behavior), in some respects much like DTOs, they communicate data about an event and … Read more

What’s the difference between Data Modelling and Domain Modelling?

Good question, the problem is that it depends on the definion of the terms, I think they differ slightly based on the sources. I would agree with previous answer – domain models are for describing the problem domain, at least the part you need to develop a solution. You describe all the various entities, their … Read more

DDD: do I really need to load all objects in an aggregate? (Performance concerns)

Take a look at this Effective Aggregate Design series of three articles from Vernon. I found them quite useful to understand when and how you can design smaller aggregates rather than a large-cluster aggregate. EDIT I would like to give a couple of examples to improve my previous answer, feel free to share your thoughts … Read more

Decompose microservices: Business capability vs Domain

The commenters are right – there are some subjective definitions at play here. But there are some principles and concepts that can help reason about the different approaches. Conway’s Law It’s not strictly the original definition, but I think the distinction can be better understood with reference to Conway’s Law: Any organization that designs a … Read more

Domain Driven Design – how the layers should be organized?

Speaking in terms of more “classical” DDD, yes domain objects are typically not allowed anywhere outside of the domain. But it is not an absolute rule that domain objects are not used in the presentation layer. For example, Naked Objects represents a school of thought where domain objects are used directly. I myself adhere mostly … Read more

DAO, Repositories and Services in DDD

Repositories are – like you say – an abstraction. They originate from Martin Fowler’s Object Query Pattern. Both Repositories and DTOs can simplify database persistence by mapping persisted data to equivalent collection of entity objects. However, Repositories are more coarse-grained than DAOs by providing control of an entire Aggregate Root (AG) often hiding a lot … Read more

How do Repositories fit with CQRS?

I’ve read about CQRS systems that maintain a simple key value store on the command side to represent an application’s state, and others that merely correlate messages (using some sort of saga) and utilise the query store to represent an applications state instead. Either way there’ll no doubt be a persistence technology involved with these … Read more