> I've been asked a question to which I don't immediately have a (good)
> answer...
>
> why is it in cake that this:
>
> public $components = array('AuthComponent');
>
> is preferred over
>
> public $Auth;
>
> public function __construct() {
> $this->Auth = new AuthComponent();
>
> }
>
> I actually really like the way its done in Cake, but have been told its
> "less readable" (a point I disagree with)....
>
> wondering if there is any major technical reason for favoring one over the
> other. Curiosity more than anything...Is it purely to reduce lines of code?
> or to make code generation easier? or to facilitate testing?...
in 2.0 Lazy loading. The classes you declare are not instanciated
until you use them.
In 1.3 and before it has various benefits, one of which is: if you
used your __construct code your app would flat out break because
you're overriding a method, giving it a different signature, and not
calling parent etc.
AD
--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
No comments:
Post a Comment