![]() |
Making code more DRY
I am currently working in CodeIgniter. I'm building an Admin for a website and basically doing CRUD over and over. I am attempting to now just build a base class that can take care of most of the behaviors I need and then just override whatever else.
Here is what I attempting for a base class. I'm not quite sure where to go with this at all. PHP Code:
PHP Code:
|
There will be a little repitition, it's kinda hard to cut down on without getting extremely complex in your code. I have found however, that by switching to Kohana I have been able to cut back on a lot of extra work with views and a few other things by using their template_controller and all their factory chaining goodness :D
I have a similar app where I had to design an admin page. I didn't write a bunch of the same stuff over and over again, but I did need authentication a lot (which I used Simple_Auth for). I wrote a class to extend the template_controller (for the sake of understanding, since CI doesn't have template_controller, it basically allows you to avoid requiring/using new views for headers, footers, etc) and in the constructor I have a default access level. I can pass either a required access level (such as administrator, moderator, editor or whatever) or an array of allowed groups. So I call the parent... Code:
parent::__construct(array('administrator', 'moderator')); |
| All times are GMT. The time now is 01:30 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0