Inheritance

The use of inheritance in Object Oriented languages allows you to take an object and create a new version of it that inherits its functionality, and then add your own modifications. The programmer does not need to understand, or even have access to the source code of the object that is being inherited. An analogy might be a custom car designer who uses a circuit board for controlling some aspect of the engine performance. The component can be added in like a "black box" with its external functionality understood, but with no knowledge necessary of exactly how it implements the functionality within the box.

In addition to being able to re-use existing component in your source code, Java development tools allow you to re-use visual components. If you have ever seen a development environment like Visual Basic, you will be familiar with idea of a "palette" of tools that can be dragged and dropped onto a form and then the programmer changes properties to suit the current use. Sun invented a technology it calls JavaBeans to allow this to happen, so programmers can drop a control such as a button or text box onto a form and then modify features such as the size or color without having to look at the underlying code of the Object.

An example of inheritance

The following diagram illustrates the idea of inheritance. Both Canine and Feline are sub classes of Animal. They share common characteristics. Tiger and Lion are sub classes of the class Feline. This style of diagram with an arrow going from the sub class to the parent class is based on UML or Unified Modelling Language. UML is an entire subject of its own, and I will not be going into any more detail than to occasionally using the diagramming conventions. You can find out more about UML at http://uml.tutorials.trireme.com/

Illustration of inheritance with canines and felines

Last modified: Sunday, 20 September 2015, 07:21 PM