I apologize if this is a duplicate, but I couldn't find any concrete examples on the topic in related questions.
After reading Martin Fowler's article on the 'Anemic Domain Model', I'm left wandering as to why is this considered an anti-pattern. Even does the majority of enterprise developers consider it an anti-pattern, since AFAIK probably 90% of the j2ee applications are designed in an 'anemic' way ?
Can someone recommend further reading on the topic (other than the 'Domain Driven Design' book), or even better, give a concrete examples on how this anti-pattern is affecting application design in a bad way.
Thanks,
Given the following two classes:
class CalculatorBean
{
//getters and setters
}
class CalculatorBeanService
{
Number calculate(Number first, Number second);
{
//do calculation
}
}
If I understand correctly, Fowler is stating that because your CalculatorBean
is just a bunch of getters/setters you don't gain any real value from it and if you port that object to another system it will do nothing. The problem seems that your CalculatorBeanService
contains everything that the CalculatorBean
should be responsible for. Which is not the best as now the CalculatorBean
delegates all of its responsibility to the CalculatorBeanService