Developing Change Handlers

The creation of Business Entities allows business logic to interact with rows in database tables as objects, such that business methods can be invoked on those objects to perform some business function.

Entities react to proposed changes in their state. Because of object encapsulation, outside callers are not to be exposed to internal validations and cascading state changes within the objects they interact with. Nonetheless, it is necessary to have a way of programming the internal logic of entities. This is the reason for Change Handlers: to enable objects to react to proposed changes in their state.

Change Handlers are classes that add behavior to entities. This behavior takes two forms.

  • Validation rules. This allows for proposed changes to be validated against business rules. These rules are expected to be side effect free, meaning that the validation does not change the state of the system. By calling side effect free validations only after all changes to entity state have been performed, the framework can avoid many complex scenarios where invalid data can slip past validations.
  • Cascading change logic. This allows changes to this entity to cause changes to other entities.