Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which are common DDD (Domain-Driven Design) patterns?

Specification pattern is a common pattern used in DDD that encapsulate business logic to respond to one question.

public interface ISpecification<T>
{
    bool IsSatisfiedBy(T aSource);
}

public class CustomerHaveDiscountSpec : ISpecification<Customer>
{
   bool IsSatisfiedBy(Customer aCustomer)
   {
       /* ... */
   }
}

Which other patterns are common in Domain-Driven Design?

like image 718
Amir Rezaei Avatar asked Nov 03 '10 19:11

Amir Rezaei


People also ask

What is DDD pattern?

DDD patterns help you understand the complexity in the domain. For the domain model for each Bounded Context, you identify and define the entities, value objects, and aggregates that model your domain. You build and refine a domain model that is contained within a boundary that defines your context.

What is DDD example?

An aggregate is a domain-driven design pattern. It's a cluster of domain objects (e.g. entity, value object), treated as one single unit. A car is a good example. It consists of wheels, lights and an engine.

What is domain in DDD architecture?

Domain-driven design (DDD) is a software design approach focusing on modelling software to match a domain according to input from that domain's experts.

Is DDD architectural pattern?

Domain-Driven Design (also known as DDD) is an approach to software development for complex needs by connecting the implementation to an evolving model. This architectural pattern was created by Eric Evans, He has a book DDD patterns based on author experience while developing using Object-Oriented techniques.


1 Answers

I recommend InfoQ's Domain Driven Design Quickly, which does a good job of distilling the (too) longer book by Eric Evans. Building upon @Pangea's answer, the objects list deserves some description:

  • Repository: encapsulates persistence and search - typically database
  • Service: stateless API entity used for aggregate root CRUD
  • Aggregate Root: an entity whose other child composite entities lack appropriate meaning without it - perhaps the most important aspect from an API perspective when talking about DDD
  • Value Object: entity whose state does not change after instantiation (e.g. Color), particularly useful in multithreaded programming because using such eliminates concurrency issues
like image 184
orangepips Avatar answered Nov 25 '22 14:11

orangepips