In Item 2 of Effective Java (2nd Edition), the author mentions the following about imposing invariants on parameters while using Builders:
It is critical that they be checked after copying the parameters from the builder to the object, and that they be checked on the object fields rather than the builder fields (Item 39). If any invariants are violated, the build method should throw an IllegalStateException (Item 60).
Does this imply that after the build method has created the target object, it should be passed to a validation routine for any required validations?
Aucun commentaire:
Enregistrer un commentaire