I am doing some development work in which i am making one class file which will do the validation of method arguments. i am confuse How should i design this class? Whether i make this class as singleton and then call its non static method OR make this class as normal and make the methods as static?
Can someone tell which will be the better option? Is there any other alternative to this?
Actually the module i am developing a module, it will be having around 50 classes, and around 200 methods. so instead of validating method argument in every method, i want to make a class which will do it. So i will call its method from every method in another classes. So I have following options:
either create a different Object of validation class every time or Make the validation class a singleton class or make the validation method as static.
I was thinking its not good to create a new Validation class Object every time i want to validation something.
I agree with marc, furthermore I could see a case for making a Validator object a field of the class. It seems to me that different use cases could have different validation rules that are such that you would need to configure them before hand.
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peter