Tuesday 5 February 2013

Inheritance


  • A class is typically developed to represent a group or category of objects
  • An object is an instance of a class
  • When an object is created(instantiated) it is given both the attributes and behaviors that are defined in that objects class
  • In addition to this, attributes and behaviors can be inherited from other classes
  • In fact inheritance hierarchies can be formed allowing classes to be developed by simply specializing existing classes
  • As an example, think of kitchen appliances such as a toaster, fridge, juicer, mixer and stove
  • Each of these groups of objects can be modeled with a class definition, however each of these groups of objects also belongs to a broader group called appliances
  • By defining an appliance class as a generalized class each specialized class can be provided with a base if implementation
  • This can reduce development time by promoting software reuse

No comments:

Post a Comment