Note that there are some explanatory texts on larger screens.

plurals
  1. PODDD, Doctrine2, Aggregates and ArrayCollection : how isolate domain model?
    primarykey
    data
    text
    <p>I'm trying to work effectively with <strong>DDD</strong> and <strong>Doctrine2</strong> on a project with lot of business logic.</p> <p>This is pretty new to me, I'm a reading many articles and code examples to understand the main principles and practices of DDD.</p> <p>I understand that <strong>we need decouple the domain objects</strong> from other concepts related to the system, ie in a layered architecture, "the domain layer" must be isolate from other layers, like the persistence layer / service (Doctrine2 for me).</p> <p>But there is one thing it's hard to understand for me : in several code examples of ddd with doctrine2, <strong>aggregates in domain entities are managed with Doctrine ArrayCollection</strong>, I found this kind of code :</p> <pre><code>namespace Acme\Domain\Model\Users; use Doctrine\Common\Collections\ArrayCollection; class User{ //... /** * Collection of Roles * * @var Collection of Roles */ protected $roles; /** * Constructor. */ public function __construct() { $this-&gt;createdAt = new \DateTime(); $this-&gt;roles = new ArrayCollection(); } public function getRoles() { return $this-&gt;roles; } //... } </code></pre> <p>For me, this implementation create a <strong>high coupling between domain models and the persistence service</strong>, Doctrine2. </p> <p>On the other hand, if DDD Entity and Doctrine Entity classes are decoupled, there is to many layers / classes, in my opinion. What do you think ? Is there a better way to avoid / handle this ?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload