Encapsulation: Promoting reusability of rules with minor variances [LSA Data Excellence]
How to promote reusability of encapsulated rules that have minor variances?
For example, different Zip Code formats, different layouts of Address.
Anticipate the scenarios that will be subject to variance and consider whether you are dealing with different data or rules, or a different visualization of the same data and rules.
An Australian Address "is a type of" Address, just as a United States Address "is a type of" Address.
One option is that these are each subclasses of an Address super-class, each of which have different Zip Code validation rules, and each invoke a different address validation service.
Alternatively these could be fulfilled with circumstancing.
Perhaps the variable behavior is only with respect to the ZipCode, and that itself may be a candidate for its own class that can have subclasses with the variations.
Parameterizing your reusable rules to respond to different behaviors is a worthwhile technique.
As the Lead System Architect, know all your options and make a judgment as to whether an inheritance-oriented class model, circumstancing, or another approach delivers the right business outcome for your application's needs and your delivery team's capabilities.