Welcome Guest, Not a member yet? Register   Sign In
One big controller or many small controllers?
#1

[eluser]Kadu[/eluser]
I'm using CI since last year, but never develloped some big app... that's I'm doing now. And here is my question... what is better?? One big controller (about 1100 lines right now) or some small controllers (I can share my controller in about 4 or 5 controllers)????
I'm afraid to loose performance with that one big...

Thanks
#2

[eluser]sikkle[/eluser]
Hey Kadu,

with this size of controller, i think the choice go to the maintenance more than the micro-speed-optimisation.

So your call, if you see this become a pain to maintain, it's time to refactor your code indeed Smile

good luck !
#3

[eluser]John_Betong[/eluser]
Hi Kadu,

I am in the process of trying to get rid of a Big Controller and ultimately hope to delete my Big Controller
 
The steps I am using are:

1. Create a Master Controller that contains numerous common routines copied from the Big Controller.
2. Each new Small Controller is extended with the Master Controller.
3. Revising my ./config/router.php file so each new Small Controller is called before the old Big Controller.

 
The advantages are:

a. Easier to maintain and debug Sad
b. Easier to add new functionality.
c. Code should load quicker since the new Small Controllers are a fraction of the size.

 
 
#4

[eluser]Kadu[/eluser]
That what I was thinking... thanks guys, I'll do that.
#5

[eluser]Phil Sturgeon[/eluser]
I try and keep my controllers as small as possible. Remember that PHP will compile all the code in your files, even that which is not used. Meaning the more code in each file, the more work it has to do on each page load.

If you use modular extensions, matchbox, etc then you can make many controllers in each module and still have your work grouped nicely.




Theme © iAndrew 2016 - Forum software by © MyBB