What is the best design pattern for PHP when Class_a only occasionally needs Class_b information?

This project is in PHP, but is quite a language agnostic. I am creating a project that has the following MVC format

Main_Class
Main_Class_Common
  --> Class_A
  --> Class_B
  --> Class_C
  --> Class_...
  --> Class_K

The original queries go into Main_Class, which then includes the corresponding main subclass. Most queries will only require access to data in their class. However, there is a small bit of interclass data. All subclasses must have access to common common functions in Main_Class_Common at any time.

For instance,

Main_Class
Main_Class_Common
  --> Class_Projects
  --> Class_Clients

Typically, Class_Projects never needs data from Class_Clients, with the exception of one function, you may need to call it $class_clients->get_client_details($client_id);, and the same thing happens in reverse order.

$main_class_common->clean_input($myinput);.

Class class_a extends main_class_common() , . - Class_B Class_A, $class_b Main_Class_Common, ?

, .

+3
1

. Class_ProjectRepository class Class_ClientRepository, , get_client_details($client_id).

MVC . , Class_Projects, Class_Clients Class_ClientRepository .

DAL. , , Class_Client , , DAL .

+1

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


All Articles