Wednesday, May 2, 2012

DDD Examples


  1. For example, I am working on some software right now where you basically have an estate which can have a number of sites and all I seem to be modelling is Estate.AddSite, Estate.RemoveSite etc. And the only thing I seem to be putting in my domain object is validation e.g. the Site description cannot be blank…
    Would you class these as domain methods or just service layer methods?
    I think you’re right in terms of this takes a whole different mind set !

  2. udidahan Says:
    Andrew,
    I think that the issue is that the UI you’re supporting is exposing that kind of functionality to the user. DDD applies to UI design as well.
    The code in the post is indeed the implementation of service layer methods.

see main article http://www.udidahan.com/2008/02/15/from-crud-to-domain-driven-fluency/

More examples:
http://www.udidahan.com/2008/02/29/how-to-create-fully-encapsulated-domain-models/

http://msdn.microsoft.com/en-us/magazine/dd419654.aspx

By Jimmy Bogart: http://vimeo.com/43598193 He demonstrates how to transform an anemic domain model to a "wicked" domain model. One of the objectives of doing DDD he says is to protect the code from developer mistakes. The way to do so is to remove operations on properties of model objects from the calling to code to the object itself and make as much object state as necessary private (encapsulation). He also demonstrates how to refactor a switch statement down to the enum equivalent in .NET which is a pattern whereby an abstract class representing the enum (and having similar functionality) contains private classes that inherit from the outer abstract class. These private classes do/return whatever was in the case blocks. The abstract class exposes instances of these classes via separate public static getter methods with names that match enum names, and so the calling code gets polymorphic behavior based on what's returned.

No comments:

Post a Comment