CodeIgniter Forums

Full Version: The most used Design Patterns with a CI project?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello everyone,

I wonder what are the most used OO Design Patterns you guys use along with your CI projects?

I'm asking this because sometimes I kind of end up writing heavy controllers with a lot of complex logic and some protected methods, for example, when I have to reuse a block of code, or creating methods on MY_Controller when there is more than one controller using that logic, etc.

Another example, sometimes I worry about data/variables relying on the session library because I think it's up to us to avoid overwriting a variable, so we have to be careful depending on how many variables you are going to deal in your session. Usually, my approach is using a name convention to avoid this scenario.

I also like to write my own "domain classes", to avoid only "array organized data", these will be my objects that will represent my database tables (entities). I try to design them with some OO principles that we don't have in the relational paradigm, for instance, if I have a "one to many" relationship in the database, in the equivalent object I'll have a collection (array of child-objects).

In other words, how many other classes, and how much complex, you guys like to create besides the traditional MVC pattern?

Thanks, have a great week!
Probably the factory and adapter patterns CI 4 is using a lot more of then.