2009年3月4日星期三

Re: [fw-mvc] Strategy for MVC modularization

Hi,
This is my very own take on this.
I divide the app into modules, such as 'user', 'blog', 'forum', 'comment' modules.

In each module, I have a model that normally deals only with some module-specific tables. E.g: module 'blog' will deal with table 'blog_entries'

The model for 'user' module also provides data for other modules to use. This is similar for other modules that will be called by other modules

Regarding the controllers, if the app is modular then each module is fairly "small", therefore breaking it into different controllers is not such a big deal. Having said that, I usually have an 'index', 'ajax' and 'widget' controllers for each module. And the controller name pretty much says it all.

Regards,
Hoang,




--- On Wed, 3/4/09, Seth Atkins <satkins@nortel.com> wrote:
From: Seth Atkins <satkins@nortel.com>
Subject: [fw-mvc] Strategy for MVC modularization
To: fw-mvc@lists.zend.com
Date: Wednesday, March 4, 2009, 8:50 AM

Folks,
Since I am undertaking my first true "MVC" application and using this framework, I have a practical question about app structure.
 
With databases, there are normalization rules for when to break a table into two, or how many tables are needed to store a set of data if you are following certain normal forms.
 
When it comes to an MVC app, are there similar types of rules on breaking things into controllers (like a "normalization" process for MVC)? Obviously a simple app would have one controller and many actions. But if I have a more complex app, I could certainly try to still have one controller with a ton of actions, but that probably has a number of drawbacks. The way I see it, is controllers are groupings of related actions.
 
I understand MVC architecture, at least conceptually. But I'm not aware of whether there are any rules of thumb or best practices around when to group a subset of actions into a separate controller from the rest. The problem is, I can look at sample ZF apps for the next year, but they are all simple examples that only require simple app structure, and I'm looking for guidance on a more complicated app. There don't appear to be any sample apps or guidelines that I can find anywhere that addresses this topic.
 
I guess I could even ask the same thing about "modules" too.
 

Seth

没有评论: