Welcome Guest, Not a member yet? Register   Sign In
Should HMVC modules be completely autonomous? How?

I'm currently building my first HMVC application. From what I can gather, HMVC modules should run autonomously, and offer itself as a service to other modules. Hence it is Service Oriented. A module's model functions should never be called outside of itself.

My project deals primarily with text articles. The web app has a collection of articles, with authors as users in the system. The system has a dashboard for the users, with pages for the user to edit their articles.

The current design has a dashboard module, and an articles module. This is not the entire application, of course.

When a user needs to edit/update an article, the dashboard controller calls a function in the articles model directly


The request is made from the dashboard controller because from the client side, this action is executed from views within the dashboard module.

I realize the way the update_article() function is kept in the articles module is due to Object Oriented thinking. This setup was okay initially. However it is becoming increasingly problematic. What is the right way to design for a application like this? I've considered a few alternatives

1. keep the model functions with their respective objects. i.e. keep update_article() in the articles model. When the dashboard needs to update an article, instead of making direct calls to the articles model, the dashboard controller should call the articles controller (which then calls its own model). Thus the request would be controller to controller. The articles model is never called outside of its module. This however, still is based on Object Oriented thinking.

2. create a update_article() function in the dashboard model. The dashboard controller would therefore only ever need to call its own model. The problem with this alternative, however, is that the update_article() function is used repeatedly in other modules as well. Does this mean I should have update_article() functions in all modules that need it? This would result in a lot of duplicate functions residing in different modules.

Sorry for the long question. I want to build the project right. Any advice on how to correctly approach this would be appreciated.

Theme © iAndrew 2016 - Forum software by © MyBB