Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Group code by Use Case (Modules) #149

Closed
Nex-Otaku opened this issue Apr 7, 2021 · 1 comment
Closed

Group code by Use Case (Modules) #149

Nex-Otaku opened this issue Apr 7, 2021 · 1 comment

Comments

@Nex-Otaku
Copy link
Contributor

Nex-Otaku commented Apr 7, 2021

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).

@Nex-Otaku
Copy link
Contributor Author

Moved to yii-demo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant