M
M
Michael2018-06-01 17:40:32
PHP
Michael, 2018-06-01 17:40:32

Is there a split model in ddd?

The model takes center stage in ddd. It includes data and methods of working with them. Everything is clear when the model in the application is completely controlled by the developer, but what if the application architecture is modular and allows you to include third-party modules that extend the functionality of the model.
For example, there is a User class.

class User
{
    private $name;

    public function getName()
    {
    }

    public function setName()
    {
    }
}

Now, in a third-party module, the user needs to learn how to determine whether he is good.
public function isGoodPerson()
{
    return $this->name === 'Vasya';
}

The easiest thing to do is inheritance. Immediately discard the option (module 2: isBadPerson).
It remains to create a new class that will require the User model and which will contain the desired method. This is the question: is the main principle of opp (and ddd) not violated when data is manipulated outside the class?
Violated? Then how to extend the models?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
O
OnYourLips, 2018-06-01
@OnYourLips

This is the question: is the main principle of opp (and ddd) not violated when data is manipulated outside the class?
This is fine. There are manager classes (or services) that work with object classes, but within the framework of some task.
Moreover, in my opinion, with such a campaign, you can make a system that will be better supported.

D
ddd329, 2018-09-19
@ddd329

In DDD, it is normal to define the same concept in different models. In any book on DDD it is written about limited contexts, that's exactly what they were invented for.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question