Multiple Instances of the Same Module?

Let's say, for example, that I have created a model, view, and controller for displaying website news. If I later want to implement a second news module on the site that follows the same logic but resides at a different URL and pulls data from a different MySQL table, what is the best way to accomplish that?

I know that I could simply duplicate the files and modify the queries, but that will become a hassle to maintain since I will need to modify the code twice(or three, or four times, etc. depending on how many instances of the module I want) whenever I make a change.

So, any suggestions for a DRY way to do it?

One option would be to basically build an JSON/XML API that lives in one spot. You could call into that URL from each module and pass it different parameters via the URL/Query String. I don't think that would be the best option performance wise since you have to make an extra call to the API, but if it is all on the same server it might not be too bad.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

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