M
M
Michael2016-09-08 16:47:33
Yii
Michael, 2016-09-08 16:47:33

How to connect 2 entities?

I decided to understand DDD and faced the problem of entity formation. At the moment, the project has 2 sources: its own database and API. Partially, entities intersect and you can make code that will work with 2 systems, but there are exceptions. For example, in both systems there are users of different types who do not know anything about each other and require manipulation with each separately. It is not clear how to apply DDD in such cases.
Are there any examples of such solutions?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim, 2016-09-08
@springimport

PS: I don't want to throw some shit at Yii, so I emphasize - you need to choose an implementation tool based on your needs .
You will not be able to fully implement DDD in Yii. Because Yii is not capable of this =) (it is capable, but it needs to be finished).
The essence of DDD is the allocation of a subject area and its independence from the implementation and infrastructure. That is, the subject area, your logic, should be written almost on bare objects. That is, it is generally independent, you can write a test for a domain object and it will work without a framework.
When using DDD you just need constructors, an object cannot be created unless all of its parameters are specified. And not some kind of validator or base or setters should be responsible for this, the constructor should be responsible for this!
A domain object cannot be mapped to a base within that object - that's part of the implementation. This breaks the letter S in such a thing as SOLID =)
In Yii, in fact, it will not be possible to split the application into Domain layer, Persistance Layer, Application (Service) Layer, View Layer. Because of the modular architecture. You can finish it, but why?
You need to abandon Active Record completely, put a doctrine or write your own mappers in Persistance Layer, which is crap.
In general, Yii itself is a very simple framework for simple tasks, for prototyping, for applications with a short support cycle, in which the use of ERP practices out of the box is impossible. However, I do not deny that you can write a large application on it and maybe (here I'm not sure) you can support it for a long time. Strong connectivity of all components, ActiveRecord, wretched DI container (maybe something has changed, but in the 1st versions of Yii2 it was really wretched) and so on. Read about object-oriented design, about SOLID, take a look and take another look at your Yii code. And if you really need DDD, look at more suitable solutions - Symfony, Zend.
More information is needed for your particular problem. What kind of manipulations do you want to perform with them, how users differ from each other, the objects themselves, whether they are heirs according to the Liskov principle. What kind of code that can work with both. Is this code implementation dependent or does it only use domain objects.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question