What is the Anemic Domain Model?
The English "Anemic Domain Model" Anemic Domain Model, is a Pattern design business domain-based software development (Domain), where objects representing business modeling (model) are "anemic", that is: devoid of behavior.
In this Pattern, the model objects only load the data, and the business behaviors are exposed by other classes that receive these anemic objects to process them.
What are the differences in the implementation of this model compared to the Object-Oriented Model?
The answer to this question may be controversial. Some may say that differences cannot be described because the Anemic Domain Model Pattern design is also object-oriented.
The notion of difference is born when you accept the proposition that, in object orientation, an object exposes data and behaviour. In this case, this is the difference: the Pattern design Anemic Domain Model proposes precisely that these things be separated into different objects.
A small example of the two models in the java language:
Anemic Domain Model:
class ContaaPagar {
double valorDevido;
boolean pago;
}
class BaixaContaaPagar {
void baixar(ContaaPagar contaaPagar) {
contaaPagar.pago = true;
contaaPagar.valorDevido = 0d;
}
}
Other design Pattern (DDD, for example):
class ContaaPagar {
double valorDevido;
boolean pago;
void baixar() {
// baixa esta conta a pagar
pago = true;
valorDevido = 0d;
}
}
If I’m not mistaken, the other day you made an equal/similar question, where you ended up closing... Although this is a pertinent question, do you already have any idea about the Anemic Model? Or is it homework?
– CesarMiguel
@Cesarean Michael I open this post to be a way of research for other people and have a notion with object orientation, but not with this model. And just because my questions about this subject are pertinent is not a "homework", they are my own doubts.
– Pedro Rangel
Who voted to close the question is not clear: I think you are the one who did not understand the question.
– Oralista de Sistemas
The full term is The Anemic Domain Model or Anemic Model of Domain. It’s a controversial subject. I personally think it’s an anti-pattern. If no one else answers, later from home I make a reply.
– Oralista de Sistemas
@Renan blz.. if you post your answer helps very vlw
– Pedro Rangel