tags:

views:

34

answers:

0

I'm mostly an OOP newbie, and am fiddling around in CodeIgniter building a very basic ORM (maybe for future usage - now mostly for learning).

At this point I have a large class called ORM which my models extend. So a widgets model will have methods like get() (which basically gets all the rows in the 'widgets' table), and get_with_related(), etc.

I'd like to split up this class into a few smaller ones. Maybe if I have a base ORM class, and a 'reader' class (which has get(), etc.), a 'writer' class (which would have update(), save(), etc.), and maybe a utilities class.

What would be the best way to accomplish this? Should I just include and instantiate the reader and writer classes in the constructor of the base ORM class and use it like this?

$widgets = new Widgets();
$all_widgets = $widgets->reader->get();

$widgets->writer->update('description', 'here is a new description', 357);

Is there a term I can google to find out the ways of organizing classes like this?