note 28619 added to language.oop
| From: | mcoakley at netplay dot net | Date: | Sat, 18 Jan 2003 02:47:42 +0000 |
| Subject: | note 28619 added to language.oop | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-42327@lists.php.net to get a copy of this message | ||
In response to the comments above and using tomcats example directly... I love scripting languages
and I love PHP the most out of them. While most programmers (and editors notes) try to state that
PHP is not a true OO language it has what you need to develop good OO programs. Sure some of the
really strong structured things aren't there but that is the fun you get with scripted
languages. But after reading every comment on this page I think people (and I know I am going to get
flamed for this one...) should start to fully understand the principles of OO programming:
Encapsulation, Polymorphism and Abstraction.
For those new to those terms:
- Encapsulation is what you get when you can have data and the methods that act on those data in an
"encapsulated" entity (object)
- Polymorphism is a property of objects that comes through inheritence that allows methods of the
same name to perform different (but similar in purpose) actions
- Abstration provides a mechanism to design effective OO heirarchies by pulling common methods or
actions into superclasses and using inheritence to provide functionality
If these principles are understood fully, PHP can be used as a great OO language. Another common
complaint is that PHP doesn't offer private/protected members/methods, I too would like to see
these features. One BIG thing to keep in mind while desiging an OO program is that the objects
should provide funtionality at the class level. Don't think of objects as individual entities
but think of a heirarchy that provides "blackboxes" of code. In otherwords the class names
should tell you what the object does and the methods only tell you how to invoke the functionality.
You should never be concerned with how the object achieves its functionality. To demonstrate these
principles more fully (and please do not take this as a finite example) I will create a real simple
form building object heirarchy.
Post is too long, so example will be my next post...
--
http://www.php.net/manual/en/language.oop.php
http://master.php.net/manage/user-notes.php?action=edit+28619
http://master.php.net/manage/user-notes.php?action=delete+28619
http://master.php.net/manage/user-notes.php?action=reject+28619