Python

Domain Driven Design in Python 101

Domain Driven Design basically means to let business logic decide on object model, and construct the rest of the code from that starting point. Instead of, say, starting off by designing db schema and build from grounds up.

When combining DDD and Python, we get some interesting use cases. For example, if there is an order class Order, we can define the following methods:

  • __eq__: equal to
  • __gt__: compare
  • __hash__: representation

And even expressing domain concepts with exceptions:

raise OutOfStock('PAPER')
Standard

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.