Re: Package proposal: Net_Ip
| From: | Stefan Walk | Date: | Fri, 30 May 2003 15:31:07 +0000 |
| Subject: | Re: Package proposal: Net_Ip | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-16842@lists.php.net to get a copy of this message | ||
On Fri, May 30, 2003 at 05:17:24PM +0200, cagrET wrote:
> > > do u really think that using
> > >
> > > Net_Ip::get();
> > >
> > > is faster than
> > >
> > > $ip->get()
> >
> > I don't think, I know.
>
> ehh If u prefere making ur code more complex by addin everywhere
>
> [php]
> if (isset($this)) {
> $this->method();
> } else {
> Class_name::method();
> }
> [/php]
>
> ... do it ....
> but i think that this is unnecessary in most cases
You are right, it is. You don't check for $this, you simply call
the method statically. Since your `object' has no inner state, it
doesn't matter.
> > If you need to change a class name, you have done something wrong.
>
> thats the point
I meant: You should have thought better about your design before. But
that doesn't matter, because:
> After coding a lot, u see that u did smth wrong, and have to change class
> name
> what do u do know ? I will simply change 1 line of code
> U will have to change XXX lines of code
And i do so by typing one simple thing: :%s/oldclass::/newclass::/g
and voila, everything is fine. I believe any editor that deserves that
name has a method to do search-and-replace.
> both have advantages and disadvantages
So, what are the disadvantages of calling methods statically if the
`object' would have no inner state anyway?
--
Regards,
Stefan Walk
<swalk@prp0.prp.physik.tu-darmstadt.de>