OO Design / Patterns - Fat Model Vs Transaction Script?

Well, the Fat model and the Transaction Script solve design problems associated with where to store business logic. I have done some research, and a popular thought suggests that all of the business logic encapsulated within the model is the way to go (mainly because Transaction Script can become really complex and often leads to code duplication). However, how does it work if I want to use the second model TDG in my business logic? Surely a Script transaction is a tidier, less connected solution than using one model inside the business logic of another?

A practical example ...

I have two classes: User and Alert. When pushing user instances into the database (for example, creating new user accounts), there is a business rule in which you also need to insert some default entries for alerts (for example, the message "Welcome to the system", etc.) . Here I see two options:

1) Add this rule as a user method and in the process create a dependency between User and Alert (or at least Data Gateway).

2) Use the transaction transaction, which avoids the dependency between the models. (In addition, it means that the business logic is stored in a “neutral” class and is easily accessible by Alert. However, this is probably not too important).

.. , - , Transaction Script . - ?

+3
3

-

+2

- Transaction Script. ( script ) (, OR, ). , OO - , , .

( ) Transcription script, ( ). .

, , Transaction script, , .

+1

. , . TS - , . , IME, , , , , , , . .

" - ". ? , , , ( ), , . , "" "" , , .

0

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


All Articles