Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

2
  • 1
    Say you have a car. It has methods Drive, Start, Stop. Now you also need a method Park. BOOOM, stuff hits the fan, because suddenly you have to either change Lorry, ElectricCar, GoCart, Tractor, etc., etc., with the methods, or, you have to implement IParkableCar which is completely nuts, because suddenly GoCart is not a parkable car. Commented Aug 31, 2011 at 16:25
  • 2
    This is why OO is not well described by real-life objects. If your application is only going to call Park on ElectricCar then it's fine to implement IParkableCar on the ElectricCar class and not on the other Vehicles. But if your application needs to Park all types of vehicle then it should become a part of IVehicle and thus you MUST consider implementation on every class of Vehicle. Commented Aug 31, 2011 at 16:35