jeudi 8 juin 2017

How to architect two level inheritance hierarchy?

I assume a class which has more than one inheritance hierarchies it can be broken down into: Assume that a class airplane has 4 combinations:

1.  Subsonic & commercial
2.  Subsonic & jet fighter
3.  Supersonic & commercial
4.  Supersonic & jet fighter

Now my non-object oriented class looks like this

Class Airplane {

   Void SubsonicAndCommercial {
       print
    }

    void subsonicAndJet  {

   }

  void supersonicAndCommercial {

  }

  void supersonicAndJet {

 }

}

Now I need to break the plane class into subclasses. What’s the most common approach ? Will this be a 2 level hierarchy ? Ie Iface Plane Iface Subsonic, supersonic extends Plane
4-Subclass Jet extends supersonic, jet extends Subsonic.. etc

Aucun commentaire:

Enregistrer un commentaire