in reply to OOP Question - location of $self

I'm wondering if there isn't an unstated agenda behind this problem: performance. I suspect that you may be worrying (prematurely) about how fast your code is going to run if you have to keep passing $this around to private methods. My advice is to defer that worry, and code cleanly (meaing, pass $this) until you need to optimize. Then, keep these rules in mind:
The Three Rules of Optimization
  1. Don't.
  2. Don't.
  3. Before you do, profile.
(It is late here, and the source of these rules escapes me. Can someone fill in a source?)

Replies are listed 'Best First'.
Re: Re: OOP Question - location of $self
by virtualsue (Vicar) on Apr 16, 2001 at 16:45 UTC
    I'm wondering if there isn't an unstated agenda behind this problem: performance.

    Wellll he did say that he just wanted to save typing, so we should probably take his word for it, but preaching against optimization isn't a bad thing.

    The Three Rules of Optimization
    ...
    (It is late here, and the source of these rules escapes me. Can someone fill in a source?)

    Not sure, but while we're on the subject...

    Two Rules of Optimization:  1. Don't do it.   2. (for experts only) Don't do it yet.

    "Optimization hinders evolution" - Alan J. Perlis

    "We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil." - Donald Knuth