What is a good way to organize modules so other modules or app can easily re-use the services of another module?

219 views
Skip to first unread message

John Kevin Basco

unread,
Dec 21, 2014, 8:38:47 PM12/21/14
to ang...@googlegroups.com
There will be myapp.user and myapp.post feature modules:

### hard to re-use the services when there is some logic in the run method of a module
- myapp/
    - user/
        - controllers/
        - services/
    - post/
        - controllers/
        - services/

### One solution I can think of is to change it to this:
- myapp/
    - services/
        - user/
            - user.js
            - anotherServiceForUser.js
        - post/
            - post.js
            - anotherServiceForPost.js
    - user/
            - controllers/
                - addUserCtrl.js
        - post/
            - controllers/
                - addPostCtrl.js
                
myApp.services will house the all the services so they can easily be re-used by other feature modules or another app

### or mix module by feature and module by type
- myapp/
    - user/
        - controllers/
        - services/
            - user.js
            - anotherServiceForUser.js
    - post/
        - controllers/
        - services/

The feature modules will be:
- myApp.user
- myApp.post

and under those feature modules, there will be module by type:
- myApp.user.services
- myApp.post.services

This way, the folders for a feature module still contains all the services related to it. But the services can easily be re-used.

What is better in your opinion? and why? Or maybe you guys have better suggestions?

Sander Elias

unread,
Dec 22, 2014, 2:54:38 AM12/22/14
to ang...@googlegroups.com
Hi John,

The link is going to the part that is addressing exactly your issue!

Regards
Sander

Reply all
Reply to author
Forward
0 new messages