![]() |
![]() |
![]() | |
![]() International Sites:
|
Limitations of Object-oriented Programming in PHPWe indicated already a few times that the implementation of OOP in PHP is actually not a fully-fletched OOP since several concepts of object-oriented programming of other languages like C++ or Java are implemented in PHP only rudimentary or not at all. In the following we would like to cater to several of those missing OOP properties and the consequences briefly.
Like already mentioned in the chapter on the constructor, any destructor is missing in PHP. This makes an automated cleanup during removal of an object from the memory impossible. In most cases this circumstance is hardly noticeable in practice and can be handled with a normal function as well, whereby one has to rely on the discipline of the programmer who uses the function which is an insecure matter. It is possible in other languages to derive a class not only from one other class, but also from several classes at the same time. The new class inherits all properties of all ancestors. In PHP you can only derive from one class. Herewith PHP forfeits a certain flexibility compared with other languages, but on the other hand programmers are thereby forced to attend more to the concept of hierarchy in their work and to make better design. This makes complex libraries like the Portalsuite Objects more transparent for tiroes. The professional might miss another powerful tool for creating complex and logic object worlds. Some languages like - for instance - C++ allow to use the same function name several times if the parameter lists differ enough. This multiple use is called overloading. Often this is very comfortable since one does not have to amend and - as a frequent consequence - to „disfigure“ significant function names with type names and parameters. Currently overloading is not possible in PHP. Naturally you can compensate for this in practice by case discriminations etc. Of course this may result in a more complex code.
Continue to recommend this article: |
![]() ![]()
Direct links to the new Portalsuite 2002: |