Session Objectives:
Discuss the following:
Drawbacks of traditional programming
Need for Object: Oriented approach
Object: Oriented techniques
Discuss Object: Oriented Concepts
- Objects.
- Classes.
- Abstraction.
- Inheritance.
- Encapsulation.
- Polymorphism.
Need for OOP:
- Languages like C use the traditional programming approach for application development.
- In this approach, we divide the application into several tasks and write code for all tasks.
- Therefore, the focus in this approach is on the tasks and not on the objects.
- The traditional programming approach was not able to handle the increasing demand of software applications
The drawbacks of Traditional Programming approach are:
- Unmanageable Programs.
- Code Reusability not Optimum.
- Problems in Modification of Data.
- Difficulty in Implementation.
Benefits of Object Oriented Programming approach are:
- OOP offers better implementation.
- OOP offers better data security.
- OOP offers better code reusability.
- OOP offers more flexibility.
- OOP offers better manageable programs.
Objects:
- An object represents an entity in the real world.
- An object is simply something that is relevant to a particular application.
- An object is a concept or a thing, with defined boundaries, that is relevant to the problem being dealt with.
Classes:
- A class is a mould or a template of an object.
- A class is what defines all the data members and the methods that an object should have.
- The class defines the characteristics that the object will possess;it could also be referred to as a blueprint of the object.
- Each object is said to be an instance of the class.
- A class can contain any of the following as its members Properties / Fields,Methods,Constructors & Destructors
- Properties: A characteristic required of an object when represented in a class is called a property or a field.
- Method: A method is similar to a function, routine or a procedure; here it is associated to a class.
- Constructor / Destructor: These are special types of methods that execute when an object is initialized or destroyed respectively.
Abstraction:
- Data abstraction enhances security as use of data is restricted to certain functions only.
- Abstraction is more used where you want only a certain number of functions/methods are accessing data
Inheritance:
- We can incorporate the functionality of existing classes into any other class just by inheriting the new class from the existing class.
- The existing class is called the BASE class and the newly created class is called the DERIVED class.
Data Encapsulation:
- Grouping of data and methods into a single entity is known as Data Encapsulation
Polymorphism:
- Object: Oriented languages try to make existing code easily modifiable without changing the code much.
- Polymorphism allows functions to take more than one form.
- Polymorphism enables the same method to behave differently on different classes.