BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Presentation: Frameworks and DDD: Keeping the Model Clean

Presentation: Frameworks and DDD: Keeping the Model Clean

In this presentation recorded during QCon SF 2008, Tim McCarthy talks about preserving the purity of the domain model while using frameworks. Frameworks can be very useful when developing applications, but they can present some pitfalls, mudding the domain, if they are not used properly. The presentation is targeted at developers.

Watch: Frameworks and DDD: Keeping the Model Clean (1h)

McCarthy makes a demo of a real application using SharePoint to show how improper usage of a framework can bind the domain to SharePoint, making it difficult to change and maintain. He also exemplifies how the code should look like to have a good separation between the application and its framework.

One important concept used when modeling a domain is repositories. McCarthy’s rules for repositories are:

  • All Repositories must implement some type of Repository interface, i.e. ICustodianRepository
  • All Repositories are created via a Factory which uses Configuration and Reflection
  • Domain Model classes can use Repositories, but they can only be coupled to their interface, NOT their implementation!

Another concept addressed by McCarthy is Unit of Work. His guidelines for using them are:

  • The Unit of Work does not actually talk to the data source!
  • Repositories and Unit Of Work instances talk via interfaces and double-dispatch
  • Repositories can work with or without a Unit of Work, and vice-versa

Most of McCarthy session is a code demo targeted at developers interested in using both frameworks and DDD. On InfoQ there is more information on Domain-Driven Design.

Rate this Article

Adoption
Style

BT