DDD-Layered Architecture

How to implement DDD as a software design approach with Layered Architecture in large projects?

First, I’m gonna introduce an important pattern in Domain Driven Design which’s Bounded Context pattern. ✌️

What’s the Bounded Context?

Bounded…


This content originally appeared on DEV Community 👩‍💻👨‍💻 and was authored by Muhammed Yousry

How to implement DDD as a software design approach with Layered Architecture in large projects?

First, I'm gonna introduce an important pattern in Domain Driven Design which's Bounded Context pattern. ✌️

What’s the Bounded Context?

Bounded Context is a central pattern in Domain-Driven Design. It is the focus of DDD's strategic design section which is all about dealing with large models and teams. DDD deals with large models by dividing them into different Bounded Contexts.

For Example in the E-commerce food apps we have Order context, payment context, menu context, delivery context, checkout context, subscription context, and every context is a large model and has a boundaries and each model can work independently.
In the future,
you can easily move each context to a microservice.

Image description

What’s the DDD ?

  1. is a software design approach focusing on modeling software to match a domain according to input from the domain’s experts.

  2. is to bridge the gap between domain experts and developers by using the same language to create the same understanding

  3. the structure and language of software code (class names, class methods, class variables ) should match the business domain

EX: if a software processes food applications, it might have classes like Order, OrderPayment and Customer, and methods such as CreateOrder, AcceptOrder, checkout and.

  1. is very suitable for complex domains.

What’s the Layered (N-Tier) Architecture ?

  1. The most common architecture pattern is the layered architecture pattern.

  2. Components within the layered architecture pattern are organized into horizontal layers, each layer performing a specific role within the application.

  3. The layered architecture pattern does not specify the number and types of layers that must exist in the pattern, most layered architectures consist of four standard layers.

  4. (The layers of isolation concept ) Changes made in one layer of the architecture generally don’t impact or affect components in other layers.

Layered architecture digram example:-

Image description

DDD-layered architecture digram example:-

Image description

Project folder structure example :-
(ruby on rails project)

Image description

Why DDD and Layered Arch ?

I am now working on an e-commerce application (Food Industry)
And I was mainly working in the Order domain functionality, when we needed to change something in the code or add a new feature which was difficult and impossible because:-

  • Code complexity.
  • Inability to effectively debug.
  • Development speed issue.
  • Legacy and unstructured code.
  • Order was tightly coupled with payments and delivery.
  • There is a gap between the business and the codebase.
  • Missing the single responsibility principle.
  • There is no single source of truth.
  • Identifying layers responsibilities.
  • Readability issue.

We needed to isolate the field with known boundaries
To make our life easy in code.

The approach Pros:-

  • very suitable for complex domains.

  • The layers/domains of isolation concept.

  • Communication
    bridge the gap between domain business and developers.

  • Flexibility
    Since the system was built to model the
    business domain, it will generally be more flexible to
    change as new functional requirements would fit in
    naturally.

  • Maintainability

The approach Cons:-

  • Requires Domain Expertise.
  • Requires Developers have the knowledge of the DDD and Layered arch.
  • Costly
    1. This often results in a longer development and duration that ultimately translates to higher costs for the business, 2.Therefore it isn’t suited for short-term projects or projects where there isn’t a high domain complexity.

HINT: I will add a POC project using ruby on rails later


This content originally appeared on DEV Community 👩‍💻👨‍💻 and was authored by Muhammed Yousry


Print Share Comment Cite Upload Translate Updates
APA

Muhammed Yousry | Sciencx (2022-11-02T14:23:44+00:00) DDD-Layered Architecture. Retrieved from https://www.scien.cx/2022/11/02/ddd-layered-architecture/

MLA
" » DDD-Layered Architecture." Muhammed Yousry | Sciencx - Wednesday November 2, 2022, https://www.scien.cx/2022/11/02/ddd-layered-architecture/
HARVARD
Muhammed Yousry | Sciencx Wednesday November 2, 2022 » DDD-Layered Architecture., viewed ,<https://www.scien.cx/2022/11/02/ddd-layered-architecture/>
VANCOUVER
Muhammed Yousry | Sciencx - » DDD-Layered Architecture. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/11/02/ddd-layered-architecture/
CHICAGO
" » DDD-Layered Architecture." Muhammed Yousry | Sciencx - Accessed . https://www.scien.cx/2022/11/02/ddd-layered-architecture/
IEEE
" » DDD-Layered Architecture." Muhammed Yousry | Sciencx [Online]. Available: https://www.scien.cx/2022/11/02/ddd-layered-architecture/. [Accessed: ]
rf:citation
» DDD-Layered Architecture | Muhammed Yousry | Sciencx | https://www.scien.cx/2022/11/02/ddd-layered-architecture/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.