P is for Practical | |
PerlMonks |
Re^4: Perl OOPby Arunbear (Prior) |
on Jul 06, 2017 at 16:56 UTC ( [id://1194389]=note: print w/replies, xml ) | Need Help?? |
You're confusing the regular use of an object (which no one is arguing against) with modular design of an object (to use inheritance or not).
The analogy you gave would be relevant to this discussion if it had any semblance to design by inheritance, but it doesn't. But staying in the realm of car manufacture, we build cars by composing them out of components.Let's say you want to build (using 'inheritance') a new SmartLandRover that has additional sensors to detect when the driver is drunk, but 'inherits' other functionality from a base model Land Rover. SmartLandRover doesn't have a battery, so it must have wires connecting it to BaseLandRover so it can get power. SmartLandRover also doesn't have an engine, so it must have a shaft connecting it to the drive shaft of BaseLandRover so it can get movement. This may seem ridiculous, but we do something quite similar when we use inheritance.No one designs or builds cars like that, and with good reason.
In Section
Seekers of Perl Wisdom
|
|