For the projects I've seen, the two most popular places are inside
models/ and inside library/MyApp.
I find it easy to distinguish how do decide which ones best, here are a
few questions to answer:
* Is it a small project that will have very little upkeep and
iteractions once live? Then models/.
* Is it a large enough domain, with a potential for lots of iteration
and features over a long period of time? Then library/.
* Can the domain and the webapp be considered or even physically
built as separate projects each with their own
lifecycle/tests/build-tools/etc? Then library/.
* Can you benefit from the 1-1 naming that library/ affords you? (As
opposed to the dynamic mapping of "Application_Model_*" to
application/models/* ? Then library/.
Lastly, I'd look at how modular your app is and decide if the kind of
modularity you want to see is best served by splitting the models from
the modules' controllers and views. Sometimes the amount of segregation
that happens here is not worth it, and models/ of your modules is the
better place to go as to keep these things together.
Another thought is that depending on the size of your domain model, you
might wand to split up your classes:
* the library/MyApp/MyDomain might get all of the entities, value
objects, repositories and factories.
* the models/ folder would be all of the server layer classes that
consume your domain model
This keeps a strict separation of concerns from your webapp and your
domain model.
-ralph
On 2/1/11 1:43 AM, Joe Balancio wrote:
>
> Is it generally a hard fast rule that models should be placed in the web
> app's models folder? Or web app's module's models folder?
>
> What are some use cases where the models can be placed elsewhere, like the
> library?
没有评论:
发表评论