HMVC best practice - calling models in other modules triads?

Another question related to HMVC pattern (I'm using Modular Extensions):

In my database I have a 'categories' table which I need to interact with from different modules (MVC triads), eg.

* Module A: Returns a 'search widget' where user can check which categories to be included in a search.
* Module B: A navigational tab with links to each category.
* Module C: Admin interface for creating/deleting categories

The question - should I:

implement the database interaction with the 'category' table in each module's model?
This would mean duplicate code: modules A to C would all need to have a model method like 'get_categories()' doing the pretty much the same query in the db.

Put the interaction with the categories table in it's own module - 'Categories Module' - and have the other modules call 'Categories Module' whenever categories data is needed. This seems like the right way from a maintenance point of view, but I'm not sure if this would break the HMVC philosophy of complete compartmentalizing / modularing.

c) Something else?

(I have read different introductions to HMVC on the net, but I can't really grasp what I'm supposed to do here)


1. Never duplicate code.
2. Make common models available to the entire application via application/models.
3. If you must access a model in a different module, access it via a controller in that module.
4. Nobody really cares so long as it works.

Thanks a lot - much appreciated !

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.