BT

Clarifying Domain-Driven Design Using a Trading Application Example

| by Jan Stenberg Follow 38 Followers on Mar 24, 2015. Estimated reading time: 1 minute |

Domain-Driven Design (DDD) is an approach to building software emphasizing collaboration between domain experts, developers and others involved in order to meet business objectives, Naresh Bhatia explains introducing the DDD base concepts exemplifying with Bullsfirst, an example system of medium complexity from the financial trading domain, a domain he hopes is reasonably easy to understand.

Working with his example, Bhatia, a software architect and founder of Archfirst, has extracted what he sees as the most important concepts when learning the basics of DDD.

A Ubiquitous Language is crucial in establishing a common understanding of a domain. Using a common terminology minimizes the risk of misunderstanding in discussions involving domain experts and developers and prevents developers from using code terms describing a domain.

Bounded context is a way of dividing a large domain into smaller ones from a business perspective separating different concerns into their own context. Bhatia notes that a model should be small enough to be managed by one team.

Besides the most common concepts in a domain model, e.g. entities and value objects, Bhatia summaries a few other concepts he finds important:

  • A Domain service relates to a domain concept, often some business logic working on a group of objects and therefore not a natural part of a single entity. Often a domain service is stateless. One example from Bhatia’s example is a MatchingEngine containing business logic to match orders and execute trades.
  • Domain events represent something significant happening within a domain and can be used to decouple components by only sharing these events.
  • Aggregates are used to group associated objects together acting as a unit. One object is assigned as root and is the only member of the aggregate users can call methods on, effectively hiding all other objects. Aggregates have earlier been explained in detail by Vaughn Vernon.

Bullsfirst, the system Bhatia uses as an example, is an open source project containing a RESTful API conforming to REST Maturity Level 2 to facilitate securities trading, an Exchange responsible for order matching and execution, and an Order Management System responsible for order creation. Technologies used include Java, .NET, FIX, messaging and Web Services. The code can be downloaded here.

Rate this Article

Adoption Stage
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss
BT