I would like to resolve the following doubts about the Anemic Model:
I would like to resolve the following doubts about the Anemic Model:
The "Anemic Domain Model" is an design pattern of domain-based software development (domain ), where objects that represent business modeling are "anemic", ie devoid of behavior.
In this pattern, model objects only load data, and business behaviors are exposed by other classes that receive these anemic objects to process them.
The answer to this question may be controversial. Some may say that you can not describe differences because the Anemic Domain Model design pattern is also object oriented.
The notion of difference is born when you accept the proposition that in object orientation an object exposes data and behaviors . In this case, this is the difference: the design pattern Anemic Domain Model rightly proposes that these things be separated into distinct objects.
class ContaaPagar {
double valorDevido;
boolean pago;
}
class BaixaContaaPagar {
void baixar(ContaaPagar contaaPagar) {
contaaPagar.pago = true;
contaaPagar.valorDevido = 0d;
}
}
class ContaaPagar {
double valorDevido;
boolean pago;
void baixar() {
// baixa esta conta a pagar
pago = true;
valorDevido = 0d;
}
}
On this point, imagine that you have requests that need to go through steps. We would have a Request class, RequestEtape1, RequestEtapa2 (these two inheriting from Request), to perform step 2 I need step 1 to complete. If I adopt the DDD, how would I solve the business rule? Would the Entity2 Request entity access the Repository of RequestAtapa1?
class Pedido {
int id;
int numero;
Date dataPedido;
}
class PedidoEtapa1 extends Pedido {
Date dataEtapa1;
}
class PedidoEtapa2 extends Pedido {
Date dataEtapa2;
public Boolean etapa1Concluida() {
...
return ?;
}
}