yiisoft / app

Yii3 application template

Home Page:https://www.yiiframework.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Group code by Use Case (Modules)

Nex-Otaku opened this issue · comments

Instead of grouping project files by type, we should group them by "use cases" or "modules".

Old structure (typical for Yii2), grouping by type:

/src/Controllers/Module1/Module1Controller
/src/Controllers/Module2/Module2Controller
/src/Components/Module1/Component1
/src/Components/Module2/Component2
/views/module1/index
/views/module2/index
/tests/module1/Testcase
/tests/module2/Testcase

New refined modern structure with grouping by module:

/src/Module1/
             Controllers/Module1Controller
             Components/Component1
             Views/index
             Tests/Testcase
/src/Module2/
             Controllers/Module2Controller
             Components/Component2
             Views/index
             Tests/Testcase

1 module = 1 folder

Not only classes should be grouped by modules, but views and tests too.

Benefits:

  1. Store in one place all that is used in one business feature. For example, code with tests that testing it. Easy to find, easy to manage.

  2. Reuse module between projects with copy-paste module folder. Easy!

  3. Fork modules to reuse in same project. Just copy that folder, and replace some logic.

  4. Work in single folder at one time, tinkering some feature. No need to open 3-4 folders in project tree (code, tests, views, etc).

Moved to yii-demo