2010年8月23日星期一

Re: [fw-mvc] Re: Centralized Stack/Broker or something for Models

It seems a lot of the solutions out there rely in static classes/methods/properties. How does this affect unit testing? And how do you encourage dependency injection with your fellow developers?

--
Hector Virgen
Sent from my Droid X

On Aug 23, 2010 6:52 AM, "Christoph" <christopher@emergencyinhaler.com> wrote:
>
> I set up my model class with a static factory method and a static registry.
> So when I want to grab a user object, I call User::factory($username). The
> factory method will check if this object exists in the registry. If it does,
> return it. If not, instantiate it and store it in the registry. This way
> each user only gets instantiated once. It also keeps the logic in the model
> class itself, and out of the bootstrap and controllers.
>
>
> Marko78 wrote:
>>
>> So I was thinking, am I wasting resources? Declaring the same class over
>> and over again in the same request. Should I have somekind of centralized
>> stack where to register my Models when needed and the next time the Model
>> is needed it could be get from this centralized stack?
>>
>
> --
> View this message in context: http://zend-framework-community.634137.n4.nabble.com/Centralized-Stack-Broker-or-something-for-Models-tp2333975p2335141.html
> Sent from the Zend MVC mailing list archive at Nabble.com.
>

没有评论: