GOF recommends that all classes in this template be derived from a single abstract component class. You can get a class from an existing class to add this functionality to the DynamicComponent file with the same effect. You are extracting internal objects from this class. In this class, magic methods can be used to dynamically manage properties and routing messages. You will need the functions __get (), _set (), _ call () and possibly__construct (). I use a factory method with protected constructors to simulate multiple inheritance. factory returns a stand-alone component or a wrapped component (usually, as directed by the collector, for example, a tree builder, which, for example, receives data from a database).
Transfer functionality occurs in an abstract class, also derived from a common component class.
You provide implementations of each method in a common interface. These overriding functions synchronize data in the internal element and the external element and provide wiring for transferring raw messages to the internal element. In fact, each class participating in this template automatically gets the main functions __get () and __set () from the parent and extended from inner_item. They are bound in an abstract class to send messages to their inner_item instances. A particular shell gets a component interface that is free of it, and can focus on added functionality. If you want to get rid of the common parent, then the common interface will need to be reinstalled in each concrete wrapper class. Another advantage is the ability to add functions such as compare and __toString () to the base class. Objects can be used completely interchangeably in functions such as usort () and other list / tree / stack / cue / array / whatever structures, because they are not just similar to the same interface, they are of the same type!
source share