Template Objects

En esta ocasión quería dejarles una serie de templates con consejos para escribir 3 de los patrones tácticos relacionados a Domain Driven Design, sirven de guía a la hora de tener que implementarlos en nuestra capa de dominio.

Entities

Referencias:

  1. Not meant to be extended from
  2. Properties can be mutable
  3. Use named constructors as meaningful ways of instantiating the object
  4. Validate argument. Instantiate a new copy. Assign arguments to properties. Record domain event(s)
  5. Pass data relevant to the job, plus contextual information (current time, current user, etc.)
  6. Validate input arguments. Validate state transitions. Record domain events
  7. Limit the number of query methods exposing state
  8. Return recorded domain events

Value Objects

Referencias:

  1. Not meant to be extended from
  2. All properties are immutable
  3. Named constructors as meaningful ways of instantiating the object.
  4. Validate arguments. Instantiate a new copy. Assign arguments to properties. Record domain event(s)
  5. Use declarative names for modifiers (e.g. with…())
  6. Return a modified copy of the original
  7. Limit the number of query methods

Services

Referencias:

  1. Not meant to be extended from
  2. All properties are immutable
  3. All arguments are required. Don’t inject contextual information; make the service reusable
  4. Dependencies are actual dependencies, not service locators
  5. Only assign arguments to properties
  6. Pass data relevant to the job, plus contextual information (current time, current user, etc.)
  7. Validate input arguments. Perform the task. Produce side effects
  8. Validate input arguments. Produce no side effects, only return information
Written on January 12, 2021