Should persistence be the responsibility of a domain object? (Can you comment on this article?)

I read the article .

In the source code, Entity objects perform all CRUD operations. This means that Entity objects call the repository directly from methods.

The comments indicate:

Persistence is the absolute compatibility of a domain object

Is it correct?

+3
source share
5 answers

, , , DI, DDD. , . , .

, , , . "goto" - , .

, , . , FitNesse () - . , .

+1

" - , ": .

. .

, , , . , , . , , DDD.

+1

, Active Record. , DDD Active Record, .

. Active Record DDD .

+1

, , .

, DAO -, , .

, , . :

public class Parent {
    @Lazy
    private List<Children> children;
}

. - . DAO DAO - -, getChildren() .

Parent, , .

-: - , , -, , . , - .

, OO. , , , . -, . ? ?

OO .

+1

Without reading the article, I can say that I will never write my level of data access as part of domain objects.

Domain objects are one of the most sensitive parts of an application because they are used in all application layers. adding persistence logic inside them will cause you a lot of problems if you want to change the save layer a bit.

In addition, most of the code using this object should be indifferent to the fact that they are even stored.

+1
source

Source: https://habr.com/ru/post/1718830/


All Articles