-- johannesf <[EMAIL PROTECTED]> wrote
(on Monday, 19 May 2008, 11:17 AM -0700):
> I have been learned to allways use set/get to deliver parameters to class
> methods, best practice lite this:
> 
> $validator->setEmail('[EMAIL PROTECTED]');
> $validator->isValid();
> 
> But, in the Zend framework there are lots of places where the docs tell me
> not to do that? And insted put the parameter direct in to the method, like
> this:
> 
> $validator->isValid($email);
> 
> Why is that so? And is'nt that to "break" best practice of objekt oriented
> coding style?

Best practices depend on who's teaching them, their background, and the
language discussed. 

In PHP, we often go for expediency -- why do _two_ method calls, when
_one_ will suffice? Many see the Java-esque version you present as
verbose and unnecessary, particularly when isValid() is all you're
interested in.

Yes, it may not be pure OOP, but then again, is pure OOP for purity's
sake a necessity? ;-)

-- 
Matthew Weier O'Phinney
Software Architect       | [EMAIL PROTECTED]
Zend - The PHP Company   | http://www.zend.com/

Reply via email to