4

What is the difference between

  • A simple fields-accesors-mutators class
  • A rich-modeled class

What constitutes rich modeling in business-domain classes?

Camilo Díaz Repka
  • 4,805
  • 5
  • 43
  • 68

2 Answers2

10

"Rich" as used here implies "rich behavior" (as opposed to state).

There is technical behavior and domain behavior. Accessors and mutators are technical; they lack the "why" which defines business interest.

Domain objects represent the "why" and encapsulate the "how". Actually, all objects do that; domain objects do it specifically for business value.

Let's say you, as an employee domain object, have to request a day off of work. You have 2 options:

  1. Tell your manager and he marks the schedule.
  2. Ask your manager for the schedule and mark it.

Model 1 is rich. The "why" (vacation time) encapsulates the "how" (marking the schedule).

Model 2 relegates the manager to a simple property bag and leaks the scheduling abstraction.

Bryan Watts
  • 44,911
  • 16
  • 83
  • 88
0

When your business logic is encapsulated in your business objects. In other words, you have a Business Objects (Domain Model) layer, without the need for a separate Business Logic layer.

yfeldblum
  • 65,165
  • 12
  • 129
  • 169