• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How do you design your application? (What are your personal conventions?)

Coming from CakePHP, I'm used to there being a set way to do everything. For example, every database table has a corresponding model. From what I've read in the user guide, this is not necessarily true in CI. It seems as if the system is so flexible that your application can just have a single model that handles every database table (or a single controller for all business logic, etc) or even no model at all. Obviously, the downside of this flexibility is the potential for bad MVC practice.

So, how do you guys design your applications in this respect? The reason I am asking is because I am going to build a blog that features 3 tables: Posts, Comments, and Tags. CakePHP would have me create a post, comment, and tag model, as well as a posts, comments, and tags controller. In CI, would it be best practice to do the same? Or I could I, for example, just have a single "blog" controller and model that handles all 3 of these? At first glance, handling posts, comments, and tags would not be outside the scope of a "blog" controller or model. How would you design this app?


personally i have a model and controller for each table, but I have 25 tables in my app I am developing. I suppose its less critical in a smaller app, unless you want to extend.. having a model for each table tends to lead to more readable code.

[eluser]Michael Wales[/eluser]
I develop controllers as I feel they are necessary (not necessarily on a per-table basis) but on a per-functionality basis.

I tend to develop a model for every table (named: tablename_m) unless that table merely serves as metadata for another table.

[eluser]Majd Taby[/eluser]
What i find useful when i'm stuck is to write out your url's. That usually gives me clues to the best way i want to design my controllers ( as the url's correspond to the controllers). Apart from that, i do what walesmd and gtech do.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

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