About DDD, Repository and MVVM

Jul 27, 2010 at 1:17 PM
Edited Jul 27, 2010 at 1:19 PM

Hey, wassup ;)

I've been reviewing your code and I've some ideas for you.

You've tried to implement a very simple DDD, using Repository pattern and someway a MVVM approach.

Anyway, I found some problems from the architecture point of view:

Repository pattern must be implemented as an interface or abstract class, and all repositories will be implementing or deriving from the base one, having methods like:  

  • GetByID (id := [Identifier instance])
  • Add(some := [Instance of domain object])
  • Save(some := [Instance of domain object])
  • Remove(some := [Instance of domain object])

 

About repositories, I'm not agree that methods that are not currently related to CRUD should be implemented in this layer. I find better to serialize with models.

Any of repositories that you may implement in some application are exclusively working for translating your domain model to the underlying store (f.e. relational database, XML or whatever). That's no other thing than CRUD and basic reading operations are present in repository level. Behaviors like "find something if happens that", "remove this and do something" and so on will be in the model.

Also, repositories aren't models. You may include them in another namespace like "SomeDomain.Repositories", because this is confusing and it can encourage others to use repositories as models instead of models using repositories.

In the rest of implementation I don't find more risky things, so well done and let's see what's going on in your next release!