Under an MVC framework, which directory structure would be expected by other developers?

后端 未结 4 508
谎友^
谎友^ 2021-01-13 01:32

Generally, MVC frameeworks have a structure that looks something like:

/models
/views
/controllers
/utils

However, in a web application sui

相关标签:
4条回答
  • 2021-01-13 01:41

    It seems like 2) would be your best option, assuming you want some separation of applications. You could also have a "/common" folder at the "/app#" level for shared resources across all applications... like a shared utility class or whatever.

    0 讨论(0)
  • I usually group code by feature, so in your case grouping by application would make the most sense to me. The reason is that if I want to work on a particular feature, I shouldn't have to search through three separate folders looking for the components I need. If you group by the high level feature you know everything you need is together.

    0 讨论(0)
  • 2021-01-13 01:52

    If your apps share data, it could make sense (to me) to group the models together.

    However, for the views and controllers it probably makes more sense to keep them separate, since I'm assuming they have separate business logic and presentations.

    Further, if your apps are kept separately in version control (you are using version control, right? :), that makes the first or third option difficult to implement.

    So all things considered, I'd probably separate the apps at the top level, as in your second example.

    0 讨论(0)
  • 2021-01-13 01:54

    2 is a good start. You should consider having a common folder in which you can store any common models, views and utils used by all apps in the application suite.

    /app1
       /models
       /views
       /controllers
       /utils
    /app2
       /models
       /views
       /controllers
       /utils
    /common
       /models
       /views
       /utils
    
    0 讨论(0)
提交回复
热议问题