Inheritance and Polymorphism in PHP: Building a Form Generator - Part I (
Page 1 of 4 )
Object Oriented Programming (OOP) is a powerful technology for designing Web applications. This article is the first in a three part series that will explain two of the bases of OOP, Inheritance and Polymorphism, and apply these principles to building an extensible form generator.Introduction
If you ever tasted the power of Object Oriented Programming (OOP) in PHP, then you probably know that it's an extremely useful way to manage medium and large projects, where code reusability, extendibility and maintainability are key factors that make developing Web applications a relatively painless experience. Without a doubt, with the release of PHP 5, these advantages have been greatly enhanced due to the highly improved object model (to name a few new excellent features), which turns the present and hopefully, the future of OOP in PHP bright and extremely promising.
However, when we're talking about PHP 4, often there are complaints about the lack of support when it comes to applying OOP. Many reasons form the foundation for this criticism, such as an absence of access modifiers, lack of abstract classes and even no support for multiple inheritance. While this is all true, in fact nothing stops developers from applying OOP theory in real applications. All that you need is the knowledge to implement OOP in a fairly decent way.
Although opinions may differ (and certainly it's out of the scope of this article), I strongly believe that the limitations present in PHP 4 are easily overcome, giving programmers a valid reason to keep using OOP in PHP programming.
Since we pushed some misconceptions out of the way, it's time to focus our attention on two primary bases of OOP: Inheritance and Polymorphism. In the rest of this article, we'll introduce these concepts as they are applied in PHP, with a rather practical approach, in order to find their place in a real application: building an extensible form generator.
For experienced programmers, this surely will look like a rather boring topic. However, for beginning and intermediate PHP users, this might be a straightforward way to gracefully enter the OOP arena, without feeling completely overwhelmed. Keep reading; you'll find it's quite worthwhile.
| | Discuss Inheritance and Polymorphism in PHP: Building a Form Generator - Part I | | | | | | | Eve the subject has been treated many times on books and articles, the article is... | | | | | | That's a really awkward place to stop Part I. If you didn't have time to finish the... | | | | | | Uh, please pardon the tone of my post above. You made it quite clear in the summary... | | | | | | Your apologies are accepted. No problem about that. Even my schedule is pretty... | | | | | | In trying to understand all that was said I am a little confused about some things... | | | | | | Well I have some expirience programing php and I would like to suggest that in many... | | | | | | Sorry, I forgot to include a sample of the “alternative syntax” I was referring to.... | | | | | | Yes, you're correct. Sometimes when you have many parameters to be passed to the... | | | | | | Hi friend,
I guess you're refering to the ternary operator. Well, it's an easy way... | | | | | | Hi there,
I guess you're talking about the ternary operator. It's often used to... | | | | | | The usage of the :: syntax is the following. You can call a function defined in an... | | | | | | Thanx for the great tutorial, I've used in some way OO programing in my scripts but... | | | | | | Hi dear friend,
I'm glad you found this tutorial useful for your growing... | | | | | | Is there any reason why u decided to use PHP4 and its object syntax? Wouldn't it be... | | | | | | Despite the fact that PHP5 offers much better support for OOP, their usage is still... | | | | | | Thanks for sharing us your very nice article!
jen | | | | | | Thank you for your compliments about the article. Your comments are deeply... | | | | | | >>> Post your comment now! | | | | | |
|
 |