I would like to know what the pros and cons are for using an Anemic Domain Model (see link below).
It seems to me that Fowler's main objection is that ADMs are not OO, in the following sense. If one designs a system "from scratch" around passive data structures that are manipulated by other pieces of code, then this certainly smells more like procedural design than object-oriented design.
I suggest that there are at least two forces that can produce this kind of design:
Designers/programmers who still think procedurally being required to work in an object-oriented environment (or assuming that they can...) to produce a new system, and
Developers working to put a service-like "face" on a legacy system designed in a non-OO fashion (regardless of language).
If, for example, one were building a set of services to expose the functionality of an existing COBOL mainframe application, one might define services and interfaces in terms of a conceptual model that does not mirror the internal COBOL data structures. However, if the service maps the new model to the legacy data to use the existing-but-hidden implementation, then the new model might very well be "anemic" in the sense of Fowler's article -- e.g. a set of TransferObject-style definitions and relationships with no real behavior.
This kind of compromise may very well be common for the boundaries at which idealistically-pure OO systems must interact with an existing, non-OO environment.
An anemic domain model is an anti-pattern. Anti-patterns don't have pros.
The pros:
- You can claim it's a domain model and brag to your developer friends and put it on your resume.
- It's easy to generate automagically from database tables.
- It maps to Data Transfer Objects surprisingly well.
The cons:
- Your domain logic exists somewhere else, probably in a class full of class(static) methods. Or your GUI code. Or in multiple places, all with conflicting logic.
- It's an anti-pattern, so other developers will ask if you understand the concepts of object oriented design.
"It's an anti-pattern, so other developers will ask if you understand the concepts of object oriented design."
"An anemic domain model is an anti-pattern. Anti-patterns don't have pros."
Whether the anemic domain model is an anti-pattern is a matter of opinion. Martin Fowler says it is, a number of developers who know OO inside out say it isn't. Stating opinion as fact is rarely helpful.
An, even if it was universally accepted to be an anti-pattern, the chances are it would still have some (though relatively little) upside.
"Developers working to put a service-like "face" on a legacy system designed in a non-OO fashion (regardless of language)."
If you think of many LOB applications, these legacy systems will often not use the same domain model as you do. The Anemic Domain Model solves this with the use of business logic in service classes. You could put all this interface code inside your model (in the traditional OO sense) - but you typically end up losing modularity.