Note that there are some explanatory texts on larger screens.

plurals
  1. PODDD, handling dependencies
    text
    copied!<p>Boring intro:</p> <p>I know - DDD isn't about technology. As i see it - DDD is all about creating ubiquitous language with product owner and reflecting it into code in such a simple and structured manner, that it just can't be misinterpreted or lost.</p> <p>But here comes a paradox into play - in order to get rid of technical side of application in domain model, it gets kind a technical - at least from design perspective.</p> <p>Last time i tried to follow DDD - it ended up with whole logic outside of domain objects into 'magic' services all around and anemic domain model. </p> <p>I've learnt some new ninja tricks and wondering if I could handle Goliath this time.</p> <hr> <p>Problem:</p> <pre><code>class store : aggregateRoot { products; addProduct(product){ if (new FreshSpecification.IsSatisfiedBy(product)) products.add(product); } } class product : entity { productType; date producedOn; } class productTypeValidityTerm : aggregateRoot { productType; days; } </code></pre> <p><code>FreshSpecification</code> is supposed to specify if product does not smell. In order to do that - it should check type of product, find by it days how long product is fresh and compare it with <code>producedOn</code>. Kind a simple.</p> <p>But here comes problem - <code>productTypeValidityTerm</code> and <code>productType</code> are supposed to be managed by client. He should be able to freely add/modify those. Because I can't traverse from product to <code>productTypeValidityTerm</code> directly, i need to somehow query them by <code>productType</code>.</p> <p>Previously - i would create something like <code>ProductService</code> that receives necessary repositories through constructor, queries terms, performs some additional voodoo and returns boolean (taking relevant logic further away from object itself and scattering it who knows where).</p> <p>I thought that it might be acceptable to do something like this:</p> <pre><code>addProduct(product, productTypeValidityTermRepository){...} </code></pre> <p>But then again - i couldn't compose specification from multiple specifications underneath freely what's one of their main advantages.</p> <p>So - the question is, where to do that? How store can be aware of terms?</p>
 

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