UML Inheritance - Principles of Object Oriented Design

Loading...

Sign in or sign up now!
Alert icon
Upgrade to the latest Flash Player for improved playback performance. Upgrade now or more info.
4,669
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on Jan 22, 2010

The first of two videos on inheritance in software engineering. In this first part we see that through generalization we can avoid having to repeat code which appears multiple times and instead extract the repeating parts and only implement them once.

  • likes, 1 dislikes

Link to this comment:

Share to:

Uploader Comments (AgileJStructureViews)

  • great explanation really appreciate it.

  • @eltonpiko Thank you for commenting - I'm glad you found this video useful

  • hai paul wells,

    I have a doubt.

    1. why we need inheritance here, why cant we archive using polymorphisms ?

    eg: RentedFlat has HouseProperty and OwnerOccupiedHouse has HouseProperty

    RentedFlat r = new RentedFlat();

    r.getHouseProperty().getLocati­on();

    OwnerOccupiedHouse o = new OwnerOccupiedHouse ();

    o.getHouseProperty().getLocati­on();

  • @mrjayarajj Hi. Thanks for your comment. Inheritance does two jobs: 1. Helps with re-use through generalization (you only create/test the general parts once). 2. Lets you write frameworks against a base class or interface. (See my video on polymorphism). So in this video I'm demonstrating job 1 - re-use through generalization.

  • @mrjayarajj (continued) But you are correct, and this is a dilemma which OO designers often have to tackle. You can implement it with a delegate (HouseProperty) and it will work, but strictly speaking you are using a HAS-A relationship to model an IS-A relationship. Probably not a big problem in this simple case, but in a larger system with a few more layers of inheritance and a few more genuine HAS-A relationships (eg heating system) it could possibly be less clear to understand the design

see all

All Comments (8)

Sign In or Sign Up now to post a comment!
  • yo man, your tutorials are ill son! i'mma ace my principles of OOP paper tomorrow. catch you on the flipside, homie.

  • well done video. Great real world example. Much better than the stupid triangle, square, shape one.

  • @mrjayarajj

    By using inheritance we open the door to use polymorphism as well :).

    Ie, We can have a super (base) class to have common properties and a getLocati­on() method (this is a use of inheritance), .

    Then derived classes RentedFlat and RentedFlat classes and then these derived classes can re-define getLocati­on() (this is polymorphism, as getLocati­on() can be called regardless of the type)...

Loading...

Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more