Sobes.tech
Senior

What is DDD?

sobes.tech AI

Answer from AI

DDD (Domain-Driven Design) is an approach to software development that focuses on a deep understanding of the subject area (domain) and close collaboration with domain experts.

Key ideas of DDD:

  • Domain Model — the central element that reflects business logic and rules.
  • Ubiquitous Language — a common language understandable by both developers and business experts, used in code and communications.
  • Bounded Contexts — different parts of the system where the same terminology can have different meanings.
  • Architecture Layers — separation into layers (e.g., domain, application, infrastructure) for better code organization.

DDD helps create flexible, maintainable, and scalable systems, especially in complex business domains.

Example in Go — defining an entity and a repository:

// Entity
type Order struct {
    ID     string
    Amount float64
}

// Repository interface
type OrderRepository interface {
    Save(order *Order) error
    FindByID(id string) (*Order, error)
}

Here, the model reflects the business entity and operations with it, separated from infrastructure.