Linked by John Collins on Wed 21st Apr 2004 06:42 UTC
The purpose of this article is to give a novice programmer the basic idea of what OOP is, as implemented using PHP. Readers should have a basic knowledge of programming ie what variables are, variable types, basic methods of writing comments, and how to enter code into a text editor.
Permalink for comment
To read all comments associated with this story, please click here.
Well, I had the same question. It seems there are some applications that could use a little polimorphism (nothing vital, however).
For instance you could define a "html rendering engine" of some pages as an "abstract class". Then write code having this "interface" in mind. Then write some implementation (actually generating the html, implementing the interface).
Nothing fancy yet.
But suppose you want to change the look of the site. You only need to write another implementation and create an instance of the new one instead of the old when needing a renderer (hopefully the renderer is created only once, in one place). This separates look&feel code from the rest of the app: the rest is written (hopefully) with the renderer interface in mind, so changing implementations doesn't matter.
Switching site looks becomes easier. Well, if you need that sort of change
I'm sure similar stuff can be imagined. OOP is useful, sometimes ..
Well, I had the same question. It seems there are some applications that could use a little polimorphism (nothing vital, however).

For instance you could define a "html rendering engine" of some pages as an "abstract class". Then write code having this "interface" in mind. Then write some implementation (actually generating the html, implementing the interface).
Nothing fancy yet.
But suppose you want to change the look of the site. You only need to write another implementation and create an instance of the new one instead of the old when needing a renderer (hopefully the renderer is created only once, in one place). This separates look&feel code from the rest of the app: the rest is written (hopefully) with the renderer interface in mind, so changing implementations doesn't matter.
Switching site looks becomes easier. Well, if you need that sort of change
I'm sure similar stuff can be imagined. OOP is useful, sometimes ..