Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

jjohn (22)

  (email not shown publicly)
AOL IM: taskboy3000 (Add Buddy, Send Message)

Perl hack/Linux buff/OSS junkie.

Journal of jjohn (22)

Tuesday April 09, 2002
01:49 PM

Method, know thy $self

[ #4062 ]

Programming pet peeve #24:

Classes whose methods use a different variable name than "$self" to refer to the obligatory object reference. Sure, you might be tempted to use $this or $obj, but don't. I, and the majority of module writers on CPAN it seems, expect $self.

Drive on through. Thanks for playing!

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • Frankly, I don't give a bugger what you call $_[0], so long as you're consistent and the name you choose tells me what it's for. Personally, I choose self, for fuzzy reasons that I really must get round to articulating (so I know what they are...), but I'm not dogmatic enough about it to say anyone else should do different.
    • Because surprises aren't amusing when you're maintaining other people's code. Following conventions helps avoid stupid mistakes. For a while, I switched to using '$this'. Bad, bad jjohn. The switch served no purpose.

      Normally, I'm pretty laid back about style, but this bugs me.

      • Bah! Foo! Just look at the first line of the function, and see all the wonders that might be some other name.