Inheritance and Polymorphism in PHP: Building a Form Generator - Part III (
Page 1 of 5 )
In the last part of this three-part series of articles, we will find out how to improve the form generator we created in part II by learning about Polymorphism and adding it to the mix.Introduction
Welcome to Part III of the series "Inheritance and Polymorphism in PHP: Building a Form Generator." I hope that you had read the previous articles, Part I and Part II, so you have a good understanding of the overall concepts explained during the development of these sections.
If you haven't read the previous articles, let's take a quick look at what we've done for now. In order to try out some of the most powerful foundations of OOP (Object Oriented Programming), we've faced the task of applying Inheritance and Polymorphism in PHP, by taking a rather practical approach and using these pillars to create a specific project: an extensible Form Generator.
To begin with, we defined a base class named "formObject", which is the super class from which we derived all of the necessary subclasses to generate each form element, using the power of Inheritance in PHP. Once we created the proper subclasses, all we needed to do to create our working Form Generator is instantiate some objects from the subclasses -- and that's it, we have an extensible form generator!
Well, not so fast. If we remind ourselves of the approach taken in the previous article, we'll have to admit that using a "switch" statement to determine what type of form object we're dealing with, is extremely inefficient. Our goal is to try to fix up that method and implement a much better solution. So, what's our next route to presenting a decent approximation? The answer is Polymorphism. Sounds like another buzz word, but it's really good to learn how it can be implemented in our Web projects.
| | Discuss Inheritance and Polymorphism in PHP: Building a Form Generator - Part III | | | | | | | In this final article of the series, I expose the core concepts about Polymorphism,... | | | | | | Hi,
Thanks for the article, very cool. I am new to php and trying to learn sort... | | | | | | Thanks for the comments about the article.
In fact, integrating this set of classes... | | | | | | This is a great series of articles! Two questions though:
1) Is there any way you... | | | | | | Hello Adams,
Thank you for the comments about the article. They're... | | | | | | Here´s the full source code for each... | | | | | | Hello Alejandro.
First, thanks very much for the many interesting tutorials. A... | | | | | | Hello,
Thanks for the compliments on my PHP articles, and I really appreciate... | | | | | | Thanks very much Alejandro.
It works.
Now I need to go back and compare this with... | | | | | | I'm glad to know that all the classes I listed here were useful to get the script... | | | | | | Hi again Alejandro.
I see what my problem was.
I got stuck at the step with... | | | | | | Hello again,
I'm feeling glad of knowing that the problems has been solved. Also,... | | | | | | Dear Alejandro,
Thanks for the tutorials on php to which I'm new. Having cut and... | | | | | | Hi Vince,
Thank you for the kind comments on my PHP article. Now, concerning your... | | | | | | >>> Post your comment now! | | | | | |
|
 |