Welcome Guest, Not a member yet? Register   Sign In
My controller is huge
#1

[eluser]Unknown[/eluser]
My controller is a bit to long and I want to divide it.

Did you have any idea ?

I thought to divide it by action and I don't know if it's a good choice.
#2

[eluser]Lewis Cowles[/eluser]
Use models with functions for business logic for specific components that you have more than one of and may, or may not be database driven.

Use libraries or helpers for shared concerns between models that handle logic, but should mainly comprise of static classes.

Also try to cut out any unused data, I'm working on a bespoke ERP SaaS project at the moment for a very specific business and my CI, using this method is only about 10MB (Half the memory footprint of a vanilla wordpress install), although the raw application data footprint is several gigabytes
#3

[eluser]Aken[/eluser]
Sometimes controllers can be huge. It depends on what's going on throughout. You'd have to share it with us if you want specifics for your situation (use an online service such as Pastie or Github Gists).

Helpers and libraries are appropriate if you plan on using that particular code in more than one place. If you find yourself repeating code, these are certainly options.

Another solution to keeping things DRY is to use private/protected methods in the controller. That's a good way to separate things, also, if you really want to break apart a single method.




Theme © iAndrew 2016 - Forum software by © MyBB