2010年8月21日星期六

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

Hi Marko,

Interesting question. I don't have a clear answer for you.
But I try to instantiate my models in the init function of my controller and try to use it as a property of my controller class. This way I instantiate my model class max once per controller. 

I am curious what others have to say about your question.

Regards

J. Sanders

On Sun, Aug 22, 2010 at 6:24 AM, Marko78 <marko.korhonen@gmail.com> wrote:

Hi all,

I have application which have grown a little bit complex. I use models with
DbTables and Rows and so on.
For example, my module "user" has model User_Model_User in models subfolder,
which has various methods conserning user.

Now when my application has grown and turned complex, I have noticed that I
declare my models here and there all over again during the request.
$contentModel = new Content_Model_Content; is been called in many places
during some request on my application. Only "design pattern" I use for
models is "fat models, thin controllers", so I try to write all operations
to my model instead of writing them to my controllers.

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?

Model has created a lot of discussion before and it's role seems to be
blurred for many people (and for my self too). Let me know what you think of
this, and if you have done some wise solutions with models, I hope you can
share your solution here.

ps. now I have a solution where I have stack of Models in my Application
Bootstrap which I'll interact from action helper, view helper and from
models too.

-----
br,
--------------------------
Marko Korhonen
Technical Consultant
--
View this message in context: http://zend-framework-community.634137.n4.nabble.com/Centralized-Stack-Broker-or-something-for-Models-tp2333975p2333975.html
Sent from the Zend MVC mailing list archive at Nabble.com.



--
Met vriendelijke groet,

Jigal Sanders
A.J. Ernststraat 739
1082 LK Amsterdam
Mobiel: 06-42111489

没有评论: