Domain Driven Design - What is a Domain
What is a Domain ?
![](https://res.cloudinary.com/jerrick/image/upload/d_642250b563292b35f27461a7.png,f_jpg,fl_progressive,q_auto,w_1024/5e99918fbc1bfd001e20dfc7.png)
Folks, today I am going to talk about Domain Driven Design and what are domains in simple terms. This is my humble attempt to KISS ( Keep it Simple and Stupid) so any suggestions or corrections are most welcome.
What is Domain Driven Design ?
As mentioned formally in books , Domain-driven design (DDD) is an approach to developing software for complex needs by deeply connecting the implementation to an evolving model of the core business concepts.
Putting things simply it is :
- A way to break down a complicated business into bunch of core functionalities and identifying the rules/processes/actors of each functionality. These functionalities are termed as "domains"
- Implementing each one of the domains using the concept of domain models and capturing the domain model in code
- Apply state changes on the domain model and protect the domain model from corruption while applying it.
The above points are performed as an activity respecting the order from top to bottom.
Let's get going with the activities.
First Activity (Breaking down a complicated business into core functionalities )
Lets say following is my complicated business
"I own a library for purchasing and lending tech books and electronic data. I have users subscribed to the library to have access to the materials and I have partnered with multiple vendors to help me with the purchase of the books."
In this scenario , I want to understand what different core functions relates to the functioning of library.
![](https://res.cloudinary.com/jerrick/image/upload/d_642250b563292b35f27461a7.png,f_jpg,q_auto,w_720/5e99909e7c4adf001edfc738.png)
Each of the white hexagons mentioned above are components . They are called "domains" in DDD.
What is a domain ?
A domain is the problem space you are trying to identify and gain in depth expertise on . It is an isolated component in the whole business. Without a domain the entire current functioning of the business is incomplete. This gives room that a domain can evolve and new domains can play part in the future.
The questions you will ask in the domain discovery/identification process
![](https://res.cloudinary.com/jerrick/image/upload/d_642250b563292b35f27461a7.png,f_jpg,q_auto,w_720/5e99909e7c4adf001edfc739.png)
What are the responsibilities of the actors in the domain ?
What are the processes involved in the domain ?
What are the rules of the domain ?
Are there any systems I need to integrate with to perform activities in the domain?
This activity is nothing to do with the implementation of the domain but just discovering . It is to do with identifying problems you would like to solve in the space of your complex problem.
Lets do a domain analysis of the first functionality - Borrowing of books
![](https://res.cloudinary.com/jerrick/image/upload/d_642250b563292b35f27461a7.png,f_jpg,q_auto,w_720/5e99909e7c4adf001edfc73a.png)
a) What are the actors of the domain "Borrowing of books" in the ecosystem of library ?
- Book
- User/ Borrower
- User Subscription
- Lender ( Really ? Do we have multiple chain of libraries to know which lender lent the book to the user/borrower ? No . So we don't include lender as an actor. The lender is the library itself)
b) What is the process to borrow a book ?
I need to make sure the book is available for borrowing
Reserve the book for the borrower
Make sure the person can borrow only for 7 days and then he/she needs to return the book.
Deliver the book to the borrower ( Really ? My library doesn't do deliveries , the borrowers need to pick up the book from the library . Hence this is out of scope from my "library" ecosystem)
c) What are the business rules related to borrow a book ?
I need to make sure the borrower is a valid borrower
Has the borrower payed the monthly subscription ?
Has the borrower paid outstanding fines before borrowing the book ?
d) Any third party system Integrations ?
No. Not at this point. Everything is in house.
Second Activity ( Modelling the domain and mapping the domain into code)
The model is the solution to your problem (domain) and will be covered as part of my next article.
About the Creator
Harish Subramaniam
Passionate about software and help teach technology in a simple way .
Follow me on twitter :
@harish911
Follow me on LinkedIn:
https://www.linkedin.com/in/harish-subramaniam-a9493715/
Enjoyed the story? Support the Creator.
Subscribe for free to receive all their stories in your feed. You could also pledge your support or give them a one-off tip, letting them know you appreciate their work.
Comments
There are no comments for this story
Be the first to respond and start the conversation.