title: Implementing a class in Java
body: <p>I'm trying to write a driving simulation program and I need some help on the design. I have a interface called RoadObjects which for now contains vehicles and mammals. I need to implement different kind of cars such as trucks, sedans, semis. they have some methods in common and some unique. Later on, I will add other kinds of vehicles and mammals. I don't want to use inheritance and I am trying to do this according to design principles and patterns such as open-closed principle and factory. Now my question is, should I design it like this:</p>
  
  <pre><code>RoadObject interface
  
  Vehicle extends RoadObject
  
  Mammal extends RoadObject
  
  SedanImpl implements Vehicle
  
  TruckImpl implements Vehicle
  
  People implements Mammal
  </code></pre>
  
  <p>...</p>
  
  <p>...</p>
  
  <p>or should I just not have vehicle and people interface and do this?</p>
  
  <pre><code>RoadObject interface
  
  SedanImpl implements RoadObject
  
  TruckImpl implements RoadObject
  
  People implements RoadObject
  </code></pre>
  
  <p>New question:
  I want to use a factory pattern, to chose which kind of vehicles for example. So I make a VechicleImpl and VechicleImplFactory so it might look like this:</p>
  
  <pre><code>RoadObject interface
  
  Vehicle extends RoadObject
  
  VehicleImpl implements Vehicle
  
  Mammal extends RoadObject
  
  SedanImpl implements Vehicle
  
  TruckImpl implements Vehicle
  
  People implements Mammal
  </code></pre>
  
  <p>Is this kind of bad design? Because VehicleImpl will have a lot of duplicate methods of SedanImpl,TruckImpl etc. Or if I wanted to have an factory that createVehicle, where should this be? </p>