I’ve been working a lot on the App controller for Teal the last few days.  There is a lot of room for improvement that’s for sure and I’m finding some great opportunities to re-build the controller.  Originally we built separate controllers for each of the modules in TealCRM.  The thing is there was a lot of duplication inside of those controllers.  What we did to display Companies and People were 99% identical between the two.

Our current object structure looks like this for the App_Controller:

CI_Controller

   -> App_Controller extends CI_Controller

        -> *module_name* extends App_Controller

Now, there’s definitely not any issue with having this kind of child class structure.  The problem is that we have about 15-20 extended controllers off of App_Controller that have identical code structures.  Each module contains upwards of 600-1000 or so lines of code.  Once I’m done with the re-factoring that will probably fall to under 100 lines.  The extended module controller should be used more to handle unique circumstances in a model if needed.

The bonus in all of this change over is that by doing this re-factoring, it becomes more re-useable.  We’ll be able to allow users to configure their own modules with some tweaks in the future.  This might be something that comes sooner than later, we will see.

The goal here is to get the code cleaned up and efficient so that we can add more customization features for a more rich user and administrator experience.