Need for object-oriented paradigm
- it produces reusable code/objects because of encapsulation and inheritance.
- the data is protected because it can be altered only by the encapsulated methods.
- it is more efficient to write programs which use pre-defined objects.
- the storage structure and/or procedures within an object type could be altered if required without affecting programs that make use of that object type.
- new functions can easily be added to objects by using inheritance
- the code produced is likely to contain fewer errors because pretested objects are being used.
- less maintenance effort will be required by the developer because objects can be reused.
Encapsulation
It is the combining of data items (or attributes / properties) with procedures (methods) for manipulating those data items, into a single unit called an object.
Object
An object consists of a data structure plus a set of procedures for manipulating that data structure. The data can be manipulated only by those procedures contained within the object.
Class (Object class / Object Type)
A class is a template defining a set of objects which share a common data structure (set of attributes / properties) and a common behaviour (set of methods).
Inheritance
Inheritance is a relationship among classes/objects wherein one class/object shares the structure and/or behaviour defined in one (single inheritance) or more (multiple inheritance) other classes/objects.
Polymorphism
Polymorphism is the ability of an inherited class to customize an inherited method. Two different classes may inherit a particular method from a common parent, but they may re-define it in different ways. |