in reply to Re^3: displaying package variable from inherited method.
in thread displaying package variable from inherited method.

But in that particular case, my objects represent data files that work exactly the same way (same methods all along) but carry different data. There isn't any method in any of the "children" classes : each children class really represent a "polymorph version" of the parent class, which contains all meaningful behaviours. And actually there isn't anything in my code that rely on this or that class : except of course when reading or writing the target file, I have to read it the right way, or feed it with the right data. The data is polymorphic, not the behaviour.
Would I avoid that call from the parent to the child to call data, I'd need to duplicate most method exactly (there aren't any differences!) in all the classes. Wouldn't it be stupid and unmaintanable?
I really don't think it can be called "breaking encapsulation", because nothing in the parent classes rely on what is inside the child class.
Please shed some light on me if you feel differently...
  • Comment on Re^4: displaying package variable from inherited method.

Replies are listed 'Best First'.
Re^5: displaying package variable from inherited method.
by chromatic (Archbishop) on Jun 10, 2006 at 22:55 UTC
    The data is polymorphic, not the behaviour.

    Same thing.

    Look at how much work you're doing your way. Look at how little magic you need to do it my way.

    Encapsulation, object-wise, is hiding data behind polymorphic behavior. I don't know how to say it any more plainly than this. Mixing raw data access and polymorphism usually bites me, and I think the fragility of your solution here is evidence that it's already biting you.

      I understand your point now, thank you!