you might check out Skinny-Controller-Fat-Model designs. (e.g., http://weblog.jamisbuck.org/2006/10/18/skinny-controller-fat-model) in such case, your example might look like:
SubscriptionModel::findByEvent($event)
which you would then call from inside EventController *or* SubscriptionController. so the functionality lives in 1 place and is simply called from 2 places.
-L
@Michael: I don't think you fully understood what I mean with "overlap".
I will try to explain what I mean. For example when navigating to a event. You select an event and also might want to see the subscriptions for the event. So this is something you are going to arrange in your eventController but you might also want to get it through the SubscriptionController. This is what I mean with overlapping functionality. Not overlapping code!
@luke: I am not planning to create a model for each controller. The model is going to be my full application layer with business logic, which is going to be controlled by my application controller.--On Fri, Aug 15, 2008 at 5:14 PM, Luke Crouch <luke.crouch@gmail.com> wrote:I think you have 3 models - Events, Persons, Subscriptions.
I think each model needs its own controller to handle the basic operations for manipulating the model objects. if you're worried about duplication of code, make a parent controller class from which EventController, PersonController, and SubscriptionController extend.
You will still have 3 separate controllers, but each will be minimal and be re-using code rather than duplicating code.
-LOn Fri, Aug 15, 2008 at 8:20 AM, Michael Tramontano <mtramontano@efashionsolutions.com> wrote:
Jigal,
Generally I make a controller for every "section" of my web app. Since I keep business logic in the model layer, and the controllers can use the same zend_form's, I typically have little to no "overlap" (I'm assuming you mean repeated logic/code). While I have several controllers, I have only 1 controller layer. Perhaps this is what you've interpreted as ">If you read throughout the web about mvc. you see that an application has generally speaking one controller (which on it's turn can have many subcontrollers).".
You might need to revisit what logic and code you've put into your controllers and see if you can push any repeated code out to a shared model layer. If you have to, you can wrap this "pushed logic" in a new model class(es).
-mike tramontano
From: Jigal sanders [mailto:jigalroecha@gmail.com]
Sent: Thursday, August 14, 2008 4:50 PM
To: Zend Framework MVC
Subject: [fw-mvc] [ZF] Model arcitecture
Hello Everyone,
I have more kind of architectural question which has a lot to do with the zend MVC. My problem is as follows. Lets consider a webapplication which does something with users , events and subscriptions. The idea is that users can subscribe for events and admin's can manage the subscriptions. So far so good.
Now it's like this. The Zend framework is very clear about controller's and views. The problem is about the model on which Zend is (according to my humble opinion) not so clear. And thus I have questions about.
If you read throughout the web about mvc. you see that an application has generally speaking one controller (which on it's turn can have many subcontrollers). I have splict my application up in generally 3 main controllers (eventController, personController and Subscribtion controller). And today I was thingking about it and came to the conclusion that this is not very handy, since you always have overlapiing stuff. So I thought of 2 possible solutions.
SOLUTION 1: Keep 3 controllers wich are only connecting to the model through a (model) controller. One of the disadvantages is that I will keep struggeling with the controlles for overlapping Items.
SOLUTION 2: Merge the 3 controllers to one controller and use it to connect to the model. This will keep the most overview but one large controller.
So my question to you is what do you think about this analysis? Which solution would you choose or is ther a third , better solution?
Thanks in advance.
J. Sanders
Met vriendelijke groet,
Jigal Sanders
A.J. Ernststraat 739
1082 LK Amsterdam
Mobiel: 06-42111489
没有评论:
发表评论