Basically, while writing ruby codes, I avoid using inheritance because inheritance sometimes produce unnecessary tight couplings.
end def stop_engine
class Car < Vehicle
In this case, Car class knows about the codes of Vehicle class. If we create objects that don’t use an engine, it will necessary to take much time to change the codes.
We should use compositions. In other words, we should define Engine object.
@engine = Engine.new
end def drive
end class Engine
end def stop
In this case, Engine class was separated from Car class. Moreover, it has become easy to make new objects that don’t use an engine.
My LinkedIn account is below! Please contact me!