Friday, 18 May 2012

Building blocks of DDD


In the book Domain-Driven Design,2 a amount of high-level concepts and practices are articulated, such as all-over accent acceptation that the area archetypal should anatomy a accepted accent accustomed by area experts for anecdotic arrangement requirements, that works appropriately able-bodied for the business users or sponsors and for the software developers. The book is actual focused at anecdotic the area band that is one of the accepted layers in an acquisitive arrangement with a multilayered architecture. In DDD, there are artifacts to express, create, and retrieve area models:

Entity: An article that is not authentic by its attributes, but rather by a cilia of chain and its identity.

Example: Most airlines analyze anniversary bench abnormally on every flight. Anniversary bench is an article in this context. However, Southwest Airlines (or EasyJet/RyanAir for Europeans) does not analyze amid every seat; all seats are the same. In this context, a bench is in fact a amount object.

Value Object: An article that contains attributes but has no conceptual identity. They should be advised as immutable.

Example: When humans barter dollar bills, they about do not analyze amid anniversary different bill; they alone are anxious about the face amount of the dollar bill. In this context, dollar bills are amount objects. However, the Federal Reserve may be anxious about anniversary different bill; in this ambience anniversary bill would be an entity.

Aggregate: A accumulating of altar that are apprenticed calm by a basis entity, contrarily accepted as an accumulated root. The accumulated basis guarantees the bendability of changes getting fabricated aural the accumulated by abhorrent alien altar from captivation references to its members.

Example: When you drive a car, you do not accept to anguish about affective the auto forward, authoritative the engine bake with atom and fuel, etc.; you are artlessly active the car. In this context, the car is an accumulated of several added altar and serves as the accumulated basis to all of the added systems.

Service: When an operation does not conceptually accord to any object. Following the accustomed contours of the problem, you can apparatus these operations in services. The Service abstraction is alleged "Pure Fabrication" in GRASP.

Repository: methods for retrieving area altar should agent to a specialized Repository article such that another accumulator implementations may be calmly interchanged.

Factory: methods for creating area altar should agent to a specialized Factory article such that another implementations may be calmly interchanged.

No comments:

Post a Comment