Change 3: Adding Support for Promotion Codes

Let’s move on to a different scenario: the sales team wants to do some promotions, and they want to offer a promotion code that can be provided when placing an order to get discounted prices.

After discussion with the sales team, we have these new requirements:

  • When placing an order, the customer can provide an optional promotion code.
  • If the code is present, certain products will be given different (lower) prices.
  • The order should show that a promotional discount was applied.

Some of these changes are easy, but the last requirement, which looks so simple, will create surprisingly powerful ripples throughout the domain.

Adding a Promotion Code to the Domain Model

Let’s start with the new promotion code ...

Get Domain Modeling Made Functional now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.