Best way to break a large class into smaller ones in PHP

I am mainly a newbie to OOP and am involved in CodeIgniter, creating a very simple ORM (perhaps for future use - now mainly for training).

At this point, I have a large class called ORM, which my models are expanding. Thus, the widget model will have methods such as get () (which basically gets all the rows in the widgets table) and get_with_related (), etc.

I would like to break this class into several smaller ones. Maybe if I have a base ORM class and a reader class (which has get (), etc.), a "Writer" class (which will have update (), save (), etc.) And, Perhaps Utilities.

What would be the best way to achieve this? Should I just include and instantiate reader and writer classes in the constructor of the ORM base 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 any term I can find on Google to learn how to organize such classes?

+3
source share
1 answer

Codeigniter, /. , , . Google DAL ( ). , , . , , . .

+1

Source: https://habr.com/ru/post/1754917/


All Articles