aspose file tools*
The moose likes Java in General and the fly likes Need a pattern Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Need a pattern" Watch "Need a pattern" New topic
Author

Need a pattern

Ashish Malik
Ranch Hand

Joined: Jul 11, 2010
Posts: 50
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.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
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.

Bill
Ashish Malik
Ranch Hand

Joined: Jul 11, 2010
Posts: 50
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.

Each class has following structure:
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need a pattern