I think the arguments should be passed to the constructor. Initialize()
already gets the context as the first parameter. This breaks with the
current conventions in Agavi, tho, where __construct() is basically never
used.

We'd drop that SingletonModel class, by the way. All models, singleton or
not, will extend Model. So the "be a Singleton, baby" decision is moved from
the declaration to the code. That means that you cannot quickly change a
Singleton model to a usual model or vice versa without changing all code
lines that retrieve the model instance. I don't like this, and it was an
essential point of my previous draft that singleton and non-singleton models
should be retrieved in the code the exactly same way, but apparently there's
no way Mike and the others will agree to the approach I already implemented.
At least that's the impression I got ;)

- David


________________________________________
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of graeme
Sent: Thursday, July 21, 2005 2:26 PM
To: Mike Vincent; Agavi Development
Subject: Re: [agavi-dev] Another Singleton Model approach

To me this is addressing a different issue, I think that you could have the
Singleton Model so when the model is designed it can extend Singleton Model
rather than Model.

But I like this approach of instantiating the model. However I see a problem
with the $args and $means argument, which I think we need to address. This
goes back to the separation of constructor and initialiser methods. The
fourth methods tells how we are to create the object, whilst the third tells
what the new object should be initialised to. Will this separation be
enforced? That is will the $args be passed to the initialize() method?

graeme.


Mike Vincent wrote: 
On 7/21/05, David Zülke <[EMAIL PROTECTED]> wrote:
  
I still think there should be the possibility to have Models that implement
the Singleton pattern. I came up with another idea on how to implement it
today:

Controller:get(Global)Model() could optionally accept an array as the second
(first) argument. This array would contain two items: the model name, as
usual, and, as the second parameter, the method name the Controller should
use to retrieve an instance. So when I do

$this->getContext()->getController()->getModel('Default',
array('Navigation', 'getInstance'));
    

I do like this approach better. It sort of conflicts with another
itch, but we can possibly iron out both itches in one shot. The other
itch is not being able to pass parameters into models that have
functional constructors.  Would you be ok with the optional singleton
parameter being 4th in the method signature?

Controller::getModel($module, $model, $args=null, $means=null)

$means for lack of a better word, would be the 'getInstance' call
$args would be passed either in new Model($args) or
Model::getInstance($args)

-Mike
_______________________________________________
agavi-dev mailing list
[email protected]
http://labworkz.com/cgi-bin/mailman/listinfo/agavi-dev


  


_______________________________________________
agavi-dev mailing list
[email protected]
http://labworkz.com/cgi-bin/mailman/listinfo/agavi-dev

Reply via email to