|
Posted by Tony Marston on 06/25/06 13:50
"David Haynes" <david.haynes2@sympatico.ca> wrote in message
news:pRsng.22585$ax6.3306@fe43.usenetserver.com...
> Tony Marston wrote:
>> "David Haynes" <david.haynes2@sympatico.ca> wrote in message
>> news:Tvkng.22537$oG2.21662@fe26.usenetserver.com...
>>> Tony Marston wrote:
>>>> "Jerry Stuckle" <jstucklex@attglobal.net> wrote in message
>>>>> Actually, things like private declarations are very important. They
>>>>> are unimportant only to those who don't understand OO programming - or
>>>>> those who are sloppy in their implementations.
>>>> You don't *need* private declarations. Code will work just as well
>>>> without them.
>>>>
>>> What the heck! Let's just throw away multiply and divide. We don't
>>> *need* them. We can just use add and subtract.
>>>
>>> Heck! Why do we need subtract? We can just add negative values.
>>>
>>> Hey! Assembler works well without private declarations. Let's just pitch
>>> PHP all together.
>>>
>>> The point is that constructs are added to language to assist in the
>>> functionality and maintainability of programs written in that language.
>>> The introduction of private and protected adds to the maintainability
>>> both through its inherent protection capabilities and its clarity of
>>> intent for the maintainer.
>>>
>>> Now if PHP could just get polymorphism...
>>
>> OOP with PHP already has polymorphism. You obviously don't know what
>> polymorphism means.
>>
> Tony:
>
> PHP5 has weak polymorphism but not true polymorphism in the sense that it
> is used in OOP.
>
> You cannot, for instance, have multiple constructors for an object where
> the number of the arguments to the constructor are variable. Yes, you may
> supply default values to 'optional' arguments but consider this example:
>
> class Foo {
> function __construct($one, $two="two", $three="three") {
>
> I cannot instantiate this object as new Foo($one, $three) since there is
> no typing on the arguments and, therefore, no signature for a 'one, three'
> contructor. Nor could I define multiple __constructor() methods to allow
> for the new Foo($one, $three) case.
Polymorphism means "same interface, different implementation". It has
nothing to do with overloading.
> This type of action is common in other OOP languages such as Java and C++.
Just because those languages have to employ a certain mechanism to achieve a
certain result does not mean that EVERY language has to employ the same
mechanism to achieve the same result. Different languages work differently,
so you should expect different languages to achieve similar results with
different techniques. If everything was the same there would be no need for
different languages, would there?
> To add to the confusion from an OOP programmer's viewpoint, in order to
> invoke the 'default' value for $three, I *must* supply a value for $two.
> That is, new Foo($one, , $three) is syntactically illegal and there is
> AFAIK no way to specify that we want $two to take its default value while
> supplying a value for $three.
>
> So, maybe its not me who is unclear on the concept of polymorphism...
I repeat, overloading has nothing to do with polymorphism.
--
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
Navigation:
[Reply to this message]
|