An Architect's View

CFML, Clojure, Software Design, Frameworks and more...

An Architect's View

Martin Fowler on Domain Model Design

November 25, 2003 · 4 Comments

Martin Fowler has spotted a worrying trend in domain model design - anemia! That's his term for domain models that have no logic in them - where all of the logic has migrated to the service layer. His point is that the service layer should be fairly thin and the business logic belongs in the domain model itself.
This will be of particular interest to Mach II developers because, whilst the framework mitigates against putting too much logic in the controller portion (the XML file), you can still bulk up your listeners as a service layer and end up with too much business logic in your listeners - instead of down in the domain model where it really belongs.
If you read the Designing Models section of the Mach II Development Guide, you'll see that it recommends separating your business model (the domain model) from the Mach II framework so that your listeners don't end up full of business logic.

Tags: architecture · programming

4 responses so far ↓

  • 1 Paul Kenney // Sep 8, 2004 at 5:04 PM

    One problem that I have found is that the distinction between application logic and domain logic is not always very clear. As with many things, experience with domain modeling helps discern the two. Also, a healthy amount of refactoring will also help one see what belongs where. Its just that many chose not to take that path.
  • 2 seancorfield // Sep 8, 2004 at 5:04 PM

    Yes, refactoring is very important - I mention this in the Mach II Development Guide - and I wish more project plans reflected the fact that the first cut of the code is rarely the final cut and actually allowed time for reworking the code!
  • 3 Hal Helms // Sep 8, 2004 at 5:04 PM

    Excellent point, Sean. One of the problems of having logic in the listeners is that this behavior will apply only to that application, while the domain CFCs should be shared by many or all apps and are therefore a far better choice for placing true business logic.
  • 4 Paul Kenney // Sep 8, 2004 at 5:04 PM

    Sometimes you can't see this until you have more that just one application that exercises the model. Until you have multiple consumers of a model, the separation is more or less academic anyway.

Leave a Comment

Leave this field empty: