Whether to model a car object (and its parts such as engine) with has-a (composition) or is-a (inheritance)?
问题 I am developing a class library which will include the object Car. The dilemma is, Car itself will be a class with fields such as Registration Number, and other general information on the car. But a car has an engine, chassis, etc. These objects need to be modelled too. Should they be classes embedded within Car? If not, what is the usage scenario of an embedded class? I've learnt that composition is "part of", so you can model seperate classes and use the engine type, for example, at the