Pregunta

I am working on a decent size application in CodeIgniter, about 20 pages. Each page has unique input forms, display tables and edit data options. What I am wondering is the best way to go about structuring my application.

The two ways I have thought of:

Create a separate Controller, Model, and View for each page. 20 +20 +20 = 60 files.

OR

Create a single Controller (crammed full of code), a View for each page, and 4 Models for the entire application, one for Create, Read, Update, and Delete tasks. 1 + 20 + 4 = 25 files.

Any suggestions on the best way to go about this? Thanks to anyone in advance.

¿Fue útil?

Solución

That is for you to decide and there can be only opinions on this one.

I would suggest you to find common things in your functions and sum them up in a few controllers, models and views and make it abstract.

For example (I don't know what pages you have there) if you have one page about cats, the table is (id, name, color, height, weight) and the second table is about dogs and has the same fields (id, name, color, height, weight), you can use the same model (only send a table name from controller), same controller(you can make several methods or even do some interesting routing) and views(templates).

There are dozens of possibilities on this one, from hard coding 60 files to modular separation, HMVC, so you should see what suits you best and do it that way.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top