I am trying to categorize vehicles but I'm not sure about what is the best way to do it.
Why am I confused? If you think about it, vehicles can be categorized in a number of ways:
1) Nature of Vehicle: Land Vehicle, WaterCrafts & AirCrafts. 2) Another way of categorizing: Powered Vehicles and NonPowered Vehicles like Tractor (Non powered and just attached with truck), Truck etc. 3) Loading nature of vehicle: Vehicle can be loaded or not.
Let me take an example: Vehicle -> Land Vehicle -> Powered/NonPowered -> Loadable/NonLoadable.
If you see, I am creating many subclasses but what use of it other than property difference that it is loadable or not. I can do that using interfaces also. Implements Loadable?powered interfaces to vehicle which can allow loading.
For example: vehicle -> LandVehicle -> Tractor LandVehicle will implement interfaces like isPowered and isLoadable, which will be overriden by tractor as false and true resp.
I know that Inheritance is for "isa" relationship and interfaces for "can do" but how that make difference here because it can be used interchangeably.
What is the best way to solve such kind of problems.