J
James Miller
Howdy,
Ruby Newbie Question: When extending a class, what's the conventional
method for avoiding collisions between instance variables introduced in
the subclass and those already defined in the base class chain?
It seems the same problem can occur when using Modules for "mixins,"
too. The only suggestion I've found is to prefix one's instance
variable names with thier class names, i.e., a poor man's namespace
mechanism, which isn't very comforting. If there's no language support
for this problem, it means that to be absolutely sure that your variable
names won't collide you have to go mucking around in base class
implementations, which doesn't sound very OO at all.
Ruby Newbie Question: When extending a class, what's the conventional
method for avoiding collisions between instance variables introduced in
the subclass and those already defined in the base class chain?
It seems the same problem can occur when using Modules for "mixins,"
too. The only suggestion I've found is to prefix one's instance
variable names with thier class names, i.e., a poor man's namespace
mechanism, which isn't very comforting. If there's no language support
for this problem, it means that to be absolutely sure that your variable
names won't collide you have to go mucking around in base class
implementations, which doesn't sound very OO at all.