Login   Register  
PHP Classes
elePHPant
Icontem

Subclassing to implement customized Validation Rules?

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us

      Generic XML parser class  >  Generic XML parser class package blog  >  Processing XML with a...  >  All threads  >  Subclassing to implement customized Validation Rules?  >  (Un) Subscribe thread alerts  
Subject:Subclassing to implement customized Validation Rules?
Summary:Subclassing to implement customized Validation Rules?
Messages:2
Author:Anon Ymous
Date:2012-09-13 12:52:54
Update:2012-09-13 15:24:25
 

  1. Subclassing to implement customized Validation Rules?   Reply  
Picture of Anon Ymous
Anon Ymous
2012-09-13 15:04:48
Hi,

Nice class, but I have one suggestion:

Wouldn't it be better to implement custom validation by means of Delegation than Subclassing?

I suggest to use the Strategy-Pattern.
Maybe different strategies should then be chainable.

Kind regards

  2. Re: Subclassing to implement customized Validation Rules?   Reply  
Picture of Manuel Lemos
Manuel Lemos
2012-09-13 15:24:25 - In reply to message 1 from Anon Ymous
I guess it depends on personal preferences.

Personally I would rather not be passing yet another parameter to the class just to make it call a separate class for custom validation. Calling a function of the same class avoids the need for that extra parameter.

In any case, if you prefer to delegate to a separate object for some reason I do not envision now, you can always call it from the sub-class.