Friday, 21 June 2024

Domain Driven Design

 


Architectural Patterns  :  Reusable Solution Pattern

1. Communication Patterns

   - SOA: Services provided through a protocol, like separate services in banking systems.

   - Message Bus Architecture: Components communicate through a common channel, e.g., services in an e-commerce platform. 

2. Structural Patterns

   - Layered Architecture: Separates concerns into layers, like distinct layers in a mobile app.

   - OOAD: Uses visualization and abstraction for system models, e.g., modeling in video game design. 

3. Deployment Patterns

   - Client-Server: Server provides services to clients, like a web server serving browsers.

   - 3-Tier Architecture: Separates application into data, logic, and presentation tiers, e.g., an e-commerce site. 

4. Data Patterns

   - Data-Centric Design: Focuses on data and its transformation, like in a data analytics system.

   - DFD: Graphical representation of data flow, e.g., visualizing data flow in a retail management system. 

5. Domain Patterns

   - Domain-Driven Design: Focuses on the core domain and logic, such as patient care in a healthcare system.


Domain-Driven Design : Focus is on the business domain






  • Supporting : Auxiliary functionality, like an authentication module in software applications.
  • Core : Main business logic and functionalities, separating factor on the business like product catalogue
  • Generic : Necessary but not business-specific functionalities, like a logging module in a system.






Bounded Context

In Domain-Driven Design, a Bounded Context is like a fenced garden where specific models exist. Imagine a university with departments like Administration, Academics, and Sports. Each department, with its own rules and processes, represents a Bounded Context. The term "registration" might mean course enrolment in Academics, but signifies sports event sign-up in Sports.

In software, Bounded Contexts maintain model integrity within each area, reducing confusion and enhancing system design clarity.






Strategic Pattern

 
  • Big Ball of Mud: A system with no clear structure, like a patched, extended legacy system.
  • Anti-Corruption Layers: Protects your system from poorly designed components, acting as a translator, e.g., when integrating with an old billing system
  • Separate Ways: Developing independent systems when shared models aren't beneficial, like separate systems for production and HR in a company.
  • Open Host Services: Systems expose their functionality in a technology-agnostic manner, e.g., a bookstore's inventory system exposing data through a RESTful API.
  • Conformist: Conforming to an existing model when maintaining a separate one isn't practical, e.g., a new microservice adopting the data models of an existing system.
  • Customer/Supplier Team: One team acts as a customer and another as a supplier, like the backend team providing APIs and the frontend team using them.
  • Shared Kernel: A common model shared between different systems, like two microservices sharing a product catalogue model.

Tactical Pattern

·  Entity, Value, Aggregate Object: Entities are unique, values are immutable, and aggregates are associated objects treated as a unit. In an e-commerce app, a User is an entity, their Address is a value, and a User with their Orders is an aggregate. 

·   Repository Pattern: This pattern mediates between the domain and data mapping layers like an in-memory object collection. In a book store app, a repository handles data operations for books. 

·  Domain, Application, Infrastructure Services: Domain services encapsulate business logic; application services delegate work; infrastructure services communicate with external systems. In a banking app, interest calculation is a domain service, money transfer is an application service, and email notification is an infrastructure service.

·   Anemic and Rich Model: Anemic model separates data and behavior, while a rich model encapsulates them together. In an anemic model, an Order object holds data and a separate service handles logic. In a rich model, the Order object contains data and methods to manipulate it.










No comments:

Post a Comment

Streaming with Kafka API

The Kafka Streams API is a Java library for building real-time applications and microservices that efficiently process and analyze large-sca...