Archive for July 2014

Week 31, year 2014

  • DRY is about Knowledge - Have a look at these two classes: <?php// example 1finalclassBasket{private$products;publicfunctionaddProduct($product){if(3==count($this->products)){thrownewException("Max 3 products allowed");}$this->products[]=$product;}}finalclassShipment{private$products;publicfunctionaddProduct($product){if(3==count($this->products)){thrownewException("Max 3 products allowed");}$this->products[]=$product;}} Would you say this is duplicate code? Does it violate the DRY principle (aka “Don’t Repeat Yourself”)? If it is, then the solution to get rid of it, could be something like this: <?php// example 2abstractclassProductContainer{protected$products;publicfunctionaddProduct($product){if(3==count($this->products)){thrownewException("Max 3 products allowed");}$this->products[]=$product;}}finalclassBasketextendsProductContainer{}finalclassShipmentextendsProductContainer{} The code is identical, but why? As good Domain-Driven Design practitioners, we’d have to check with the business. The product could be a flammable chemical, and for safety concerns, a shipment is not allowed to have more than three of them. As a consequence, we don’t allow customers to order more than three at a time. In another scenario, the similarity of the code might also be simple coincidence. Maybe supply of the product is limited, and we want to give our customers equal opportunity to buy it. Reasons to Change Whatever the case, it doesn’t matter. [Mathias Verraes]
Permalink | From 28 July 2014 to 03 August 2014 | Last updated on: Mon, 7 Jun 2021 09:18:52 GMT

Week 30, year 2014

  • Event Storming: on Fake Domains and Happy Paths - Inspired by Tim Schraepen’s experience report, I thought I’d list some recent experiences with facilitating Event Storming sessions. You might want to read my older post with notes on facilitating Event Storming sessions, and the huge amount of content Alberto Brandolini has produced on the topic. Pick a good domain If you’re doing it as an exercise, as opposed to a real project, pick a real(-ish) domain. I’ve been using a government/education project for a long time, because it’s complex, vague, messy, and in constant motion. It turned out to be great domain to teach participants about challenging your own assumptions. For example, report cards that do not show grades, but observations and conclusions, some of which are written by the actual pupils! The discovery phase is quite useful, but as soon as we tried working towards a more concrete model, the rather “fluffy” domain was too hard to explain. [Mathias Verraes]
Permalink | From 21 July 2014 to 27 July 2014 | Last updated on: Mon, 7 Jun 2021 09:18:52 GMT