Why don the doAdd & doRemove methods test business rules?
Index The rationale about the add, testAdd, and doAdd methods is explained in-depth in the book on pp. 241 –245, and in our article Putting Business Rules into Business Objects. In a nutshell, we don’t put the tests in the doAdds and doRemoves because we want the flexibility of bypassing rules in special cases—when restoring an object from persistent storage, or for special trusted business services. The reason for having the doAdds is the encapsulate the implementation of the assignment in case other things need to happen when the object changes state, in case the assignment implementation changes, in case specializations want to change the assignment implementation, etc.