DEV Community

Cover image for Domain-Driven Design Core Domain
tareksalem
tareksalem

Posted on

Domain-Driven Design Core Domain

Building real projects based on software is not as easy as putting some lines of code together and deploying them to a cloud. This might work for a specific period of time, especially for the first part of a project's lifetime. However, once you start adding more functionalities to the codebase, you will fast realize that the process is bigger than that.
As a software engineer, when you get hired or have a new project to work on, one of the most important questions you should ask yourself: what does the business actually do? This question is very important; because based on its answer, you will start writing the codebase that shapes the business functionality.
Unfortunately, finding a clear answer to this question has proved tricky in many cases. For me, I don't remember that I have worked on a project with a clear answer to this question! In this case, it is important to set with people who are responsible for the business to understand what this business actually does, and assess the needs of the company.
In Domain Driven Design (the book) by Eric Evans, he calls these people "domain experts". Domain experts means "a group of people who are very experienced in the field of the business that you are going to implement the software for". These people have the needed knowledge that should help you to transform business needs into a software with the same expectations.
While you are doing this, you should keep asking yourself the main question of what this business actually does and the purpose behind it.
Actually, these questions are very important to form an important concept that will help you: this concept is called "Core Domain".
Core domain means the end value a business provides to its customers that helps them do a specific thing or get a specific benefit. Core domain helps you achieve the competitive advantage needed for customers to leave your competitors and come to you.
For Example, if I came to you and told you: "I have a Pizza restaurant, and I want you to build software that helps me deliver my delicious Pizza to my customers and enable them to order online."
From a software engineering point of view, you will find this system has only one functionality, which is delivering the product to the customer. The type of the product is less significant at this point; the focus lies at an entity called Product, an entity called Order, and an entity called Customer.
This is pretty straightforward. So far, no extra advantage over the competitors has been provided. The reason is because there is simply no personalized experience for your customers. For example, a basic Pizza includes toppings, extras, and other unique Pizza ingredients (not used for other products!). Moreover, most products have dimensions, weight, and width that describe the product, while Pizza has sizes.
All these elements are unique to the product you sell; which should help you to focus on delivering an outstanding experience to your customers. This includes building a nice algorithm that helps find the nearest Pizza branch and the shortest path to get it delivered fast. This implies utilizing a delivery vehicle with a heated compartment, to ensure that your customers receive their Pizza piping hot every time!
Among these considerations, you need to focus on what a core domain is, and how the answer can help you build the proper software.

E-commerce is not a core domain

E-commerce is everywhere, yet it is applied in different ways. However, if you asked someone who works in an applied field of E-commerce "what is your business core domain?", the expected answer would be: E-commerce! Yet, this is not the right answer in all cases! But how?
Let's take Envato marketplace as an example. Envato is a known marketplace for selling already-made websites (e.g.: WordPress websites, code kits, and other software modules). If someone asked you "is Envato an E-commerce platform?" you would say: Absolutely yes! and this is right: it's an e-commerce. However, if the question was: is their core domain the E-commerce business? the answer might be different!
To understand their core domain, we first need to analyze their business and understand the most important feature they provide.
They provide, sell and buy software pieces.
This specific type of E-commerce is their core domain. They don't sell or buy anything. In fact, they only sell specific things, which are software pieces. This specific feature will help us understand what their core domain is.
You might ask yourself what they need to do to be unique in this field? For instance, do they need a multi-vendor platform to enable their customers to buy and sell?
If the answer is "no", due to the fact that multi-vendor websites are everywhere and anyone can publish a multi-vendor website to the internet and enable customers to buy and sell! The question goes:
Do they need an out-of-the-box support system for faster customer service? This might help, however, this support system could also be bought from another provider!
What they actually need is a unique software, built and customized for them to carry the following:
A licensing system that helps them manage the sold code usage.
A code scanning/reviewing tool that helps them identify the code quality for every code piece being sold on the platform and make sure it's authentic.

If you think deeply about their business you might come up with other keys that make them unique and starting from this point you will filter these keys to specify which exactly their core domain.

How to know if E-commerce is not the core domain?

As previously said, E-commerce is everywhere, and most websites today have an e-commerce aspect in one way or another. Some websites have subscription plans to access their services, others have digital products, and other websites sell their own physical products which means their core domain is the product they are manufacturing. This means that E-commerce might be a part of any business, but not necessarily the backbone of that business in most cases. However, there are a few cases where E-commerce is the core domain of the business. One of these cases is a platform like Amazon.

Summary

Identifying the core domain of a business will significantly help you build the most proper software for the problem you are trying to solve. Even if it's not clear to you at the beginning what the core domain is, you still need to think about the business deeply to identify the unique keys. Keep in mind that the core domain could be changed from one time to another based on the business directions and needs!

Top comments (0)