2008年8月22日星期五

Re: [fw-mvc] Code re-use across modules

On Friday 22 August 2008 11:21:39 Jigal sanders wrote:
> Hello Graham,
>
> Good proposal. This is one of the things that worries me as well. I would
> like to resue some code in my model which is need in a different module.
> Shouldnt it be possible to create one model layer for all modules?

Indeed, and for some applications this would make sense. It's a commonly used
practice, to have models under this location:

application/
models

However, consider an application with a modular structure. In my case I have
several modules which provide functionality that is used not only in two or
more modules, but also in more than one application. Here's a quick example.

application/
modules/
cms/
models
forms
users/
models
forms

In the above structure, both the cms and the user module are usable in their
own right, that is to say they have action controllers and view scripts and
perform user interaction and data handling. However from the users module,
some forms and models ( user and group ) are used in more than one module and
in more than one application, and from the cms module, some content operations
are re-used across the application in more than one module ( and again in more
than one application ).

So for us, having every model class in one location is harder to maintain, and
for the most part we can just use svn externals for modules in our
applications or simply unpack a module directory archive into another app.

In addition, one project I'm working on has specific requirements to partition
the application structure and so storing all the domain logic in one location
is not an option.

没有评论: