- Anemic Domain Model
The Anemic Domain Model is a
pejorative term used to describe the use of adomain model where thebusiness logic is implemented outside the domain objects. This pattern was first described byMartin Fowler who considers the practice ananti-pattern . With this pattern, logic is typically implemented in separate classes which transform the state of the domain objects. Fowler calls such external classes "transaction scripts". This pattern is a common approach in enterprise Java applications, possibly encouraged by technologies such asJ2EE 'sEntity Bean s, [http://www.martinfowler.com/bliki/AnemicDomainModel.html] as well as in .NET applications following the Three-Layered Services Application architecture where such objects fall into the category of "Business Entities" (though Business Entities may also contain behavior). [http://msdn2.microsoft.com/en-us/library/ms954595.aspx]Benefits
* Encourages and enforces a clear separation of concerns between presentation layers, business layers, and resource access layers of an application.
* Allows for the development of a common object model which can be applied across anEnterprise while at the same time allowing for flexibility in the domain logic implementation used by differing applications.
* Enables auto-generation through modeling tools which may render a common object model in various languages used across anEnterprise .Liabilities
* Necessitates a separate business layer to contain the logic otherwise located in a
domain model . It also means thatdomain model 's objects cannot guarantee their correctness any moment, because their validation and mutation logic is placed somewhere outside (most likely in multiple places).
* Necessitates a global access to internals of shared business entities increasing coupling and fragility.
* Facilitates code duplication among transactional scripts and similar use cases, reduces code reuse.
* Necessitates a service layer when sharing domain logic across differing consumers of an object model.
* Makes a model less expressive and harder to understand.External links
* [http://www.martinfowler.com/bliki/AnemicDomainModel.html Anemic Domain Model] by
Martin Fowler
* [http://msdn.microsoft.com/en-us/library/ms978689.aspx Three-Layered Services Application]
* [http://msdn2.microsoft.com/en-us/library/ms954595.aspx Application Architecture for .NET: Designing Applications and Services]
Wikimedia Foundation. 2010.