in reply to Re: Still not getting it: hashref OO class variables
in thread Still not getting it: hashref OO class variables
Referencing class data in an object method directly makes it hard to cleanly override the object method in a sub-class. How would you write an overridden wear_out_sole()?
But it wasn't hard, and seems to work fine, as shown above in the original post (you might not've noticed that it was indeed overridden in the Boot class). Is there anything wrong with Boot::wear_out_sole in the OP?
I think there's something I'm missing here. In your comment, are you implying that a subclass should be able to access class data (since a Boot *is*, after all, a Shoe)?
All that aside, I think you'll find that it's pretty unusual to use class data in a real OO system.
Yes, I think I'm noticing that. Thank you. The only example I ever see is when a class wants to keep a total of objects. And for something that simple, there are other ways of doing it (like just incrementing a global every time you instantiate an object, or counting rows in a db table, or keeping the objects in question in a list (then you know the length of the list)).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Still not getting it: hashref OO class variables
by chromatic (Archbishop) on Feb 15, 2008 at 00:55 UTC | |
by bramble (Beadle) on Feb 15, 2008 at 01:31 UTC | |
by dsheroh (Monsignor) on Feb 15, 2008 at 16:35 UTC |