From: Dossy Date: 2002-07-06T22:32:01+09:00 Subject: Re: self_parent On 2002.07.06, Tom Sawyer wrote: > okay, i grant you i write code very differently then most others. at > least that has been my experience. i gerneally tend to hack something > out and then go over it and over and over it again trying to reduce > every little ounce of code reuse out of it that i can. i think if you > saw some on my work you'd be very suprised at how little code there is > and yet how much it does. so, when you appoach things in this way and > you have a class inheritiing a class inherting a class and so on and > those classes create other classes, to seperate logic from interface, > for example, it has been my experience that child classes need to "talk" > to their parents. > > i can provide some examples, but it won't be a tiny piece of code to > easily paste in an email. Dosen't sound like it's reduced very far. > and i think Michael, here, makes a good point: "I've passed self > before, but I can't ever remember thinking it was a good idea." And I asked: Do people never use the Visitor pattern? > that's really where i'm coming from too. for i don't feel comfortable > with passing self really. so either i'm not writing my code in the best > manner or there really is a good reason to have this connection between > the container and contained. adn yet i've i gone over some of my code > angain and again. i it always seems the most effective means: passing > self. > > perhaps i should just feel comfortable with passing self. that's fine. > i'm not trying to push this or anything. i was curious to see what > others thought. really, this conversation has me wondering what others > might thing of my code. I know two things: 1) Inheriting methods from your parent is good. 2) Needing to know what the class of your parent is a coding smell. Especially if you are using multiple inheritance. -- Dossy -- Dossy Shiobara mail: dossy@panoptic.com Panoptic Computer Network web: http://www.panoptic.com/ "He realized the fastest way to change is to laugh at your own folly -- then you can let go and quickly move on." (p. 70)