Hello Josh,

Sunday, February 22, 2004, 6:44:14 AM, you wrote:

> Sorry, mis-click.

> Quoting Josh Fuhs <[EMAIL PROTECTED]>:

>> If I'm not mistaken, Java does not allow calls to static methods via object
>> instances. It simply doesn't make sense to couple the unecessary object
>> instance
>> into a method call in which it has absolutely no bearing.
>> 
>> If the object has nothing to do with the operation, then there's no point for
>> it
>> to be in the syntax. I am completely in favor of a 
>> 
>> $stringName::staticMethod();
>> 
>> type call if this hasn't already been done.
>> 

> Continuing on...

> Consider the following piece of code:

> class Foo{
>     /* It is possible to register something with an instance. */
>     function register($param){
>         ....
>     }

>     /* It is possible to register something with the class. */
>     static method register2($param){
sidenote: there is no keyword 'method`'
>     }
> }

> /* Assume the class definition is separate from this. */

> $instance = new Foo();

> /* Hmm, the code reads register something, but I can't really be sure of 
>    the meaning without referring to the documentation. */
> $instance->register2($param);

> When reading OO (or arguably any) source, one should be able to describe what is
> happening simply by looking. A method describes what it is doing by its name. If
> a class method name makes sense for an object, a point of confusion arises for
> someone who is maintaining the code.

You are living in an oo dreamworld where any method consists of one to
three lines of code that can be described in one to three words. And not
relying on documentation is one of the biggest if not the beiggest problem
in todays software development. Learn the API, learn the specs and use tools
that allow to browse through the API/Docs - for php that means go use
phpDocumnetor. However easy spellable names are helpful of course.

> C++, though powerful, can hardly be considered the authority on OO behavior.
> Multiple inheritance and a few other features that it incorporates have not been
> accepted into the mainstream OOPLs for a reason.

> Like multiple inheritance, static method invocation via an object instance
> should be considered a bad practice.

The reason is that incorporating those features require very skilled coders
and open a hell of problems when used by people not understanding and hence
missusing them. One of the reasons for Java's success is the lack of such
powerful features that on the other hand make it possible that single team
members can kill a whole project by violating other members work, by misusing
not understood features.

For PHP we also chose to disallow/disable the complicated and problematic
features to keep PHP an easy to use language. But still we do not want to
prevent all nice oo functionality.

The reason for "static method invocation via an object instance" is the need
to move the class binding from compile time into runtime.

best regards
marcus

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to