Developing Change Handlers
The creation of Business Entities allows business logic to interact with rows in database tables as objects and in doing so allows business methods to be invoked on those objects to perform some business function. Quite another thing is how the entities react to proposed changes in their state. Outside callers have no business being exposed to the internal validations and cascading state changes within the objects that they interact with. Because of object encapsulation, they should not be exposed to such issues. Nonetheless, there needs to be a way to program the internal logic of entities. This is the reason for Change Handlers, to provide for 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.