Having developed a large set of (X)HTML widget classes that implement an “HTMLRenderer” interface, the previous article demonstrated the use of this interface through the specific definition of its abstract “toHTML()” method. In short, I’ve provided you with a technique for grouping objects of the same family type through a common interface. However, this fact itself does not give us a direct advantage in developing an application, because this functionality can be obtained by defining an abstract parent class, and then deriving some subclasses that either override or overload existing methods within the specific context of child classes. Fortunately, the existence of interfaces allows grouping objects of different family types, so if you’re working with objects that don’t belong to the same type, using a common interface to implement a specific functionality is probably the right way to go. Returning to this part of the series, I’ll demonstrate how useful interfaces can be, by implementing the “HTMLRenderer” interface on a couple of MySQL processing classes that have nothing in common with the (X)HTML widgets explained in the previous tutorial. In this way, by the end of this article you’ll have a decent background for working with interfaces as well as a clear idea about its concrete implementation in PHP applications.
blog comments powered by Disqus |