This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
I am processing an application and it involves validating it. Validation process has many rules to process. Like usual case, application passes through a set of rules and if one rule invalidates it, rest of rules don't execute and application is rejected.
Also rules tend to change for different customers. At one time only one set of customer rules will be active. How should i design my validator class so that it would only suffice to change code for the changed rule and not all rules.
Right off hand I would say you need a Validator Interface, with the actual implementing class(es) to be selected by name at runtime from a configuration file.
See the java.lang.Class.forName JavaDocs.
Joined: Jul 11, 2010
Validator interface is obvious. What i need pattern for are the rules. What i have done for another validator is create classes say: AValidator, BValidator, CValidator. (Rules were divisible into 3 categories)
Each class has set of rules defines in protected methods so that CustomeAValidator could override that method and rest would remain as such.