using record types to build better domain models

Abstract

Rules of thumbs:

  • objects from real world turn into objects in software
  • actions from real world turn into operations in software

Not everything in the real world is an object. Enters DDD.

Entity vs value objects

values from real world turn into values in software

Object is:

  • identity
  • has a life cycle
  • (mutable) state

Value is:

  • no identity
  • timeless

Example

Entity:

  • Account

Value:

  • Amount
  • Currency