I've pasted an alternate approach to the bin (I recommend you do so
with large code pastes)
http://bin.cakephp.org/view/1609330285

You'll see the approach is a little different in that I have an actual
Component (not an abstract class) that is clearly labeled as a factory
component and attached to the Controller. The Factory component then
uses logic to attach the generated object to the controller. I think
there's pros and cons to either situation. In mine, it still uses
CakePHP idioms to a certain degree (although, I readily admit there's
a slight disconnect between the Factory and the controller attachment
naming (ie: TestFactory to just Test)). In yours, you can use logic
within the action to determine how to instantiate the component but in
mine, you'd have to rely on pulling that data from elsewhere (just
like any other Component, though).

Anyways, just a thought. At first I thought, "when would you ever need
to use a factory pattern" but I can somewhat see why you've done so.

-Jonathan

On Fri, Jul 18, 2008 at 7:00 AM, keymaster <[EMAIL PROTECTED]> wrote:
>
> Here is what I came up with - it's one way to have polymorphic
> capabilities in your components.
>
> You define your component as an abstract class with abstract
> functions, and thereafter, except for a single call before you use the
> component the first time, it behaves exactly as a regular component
> would, but you gain polymorphism.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to