Step 1: Understand programming paradigms.
Earlier programming approaches mainly followed the
procedural programming paradigm. In procedural programming, programs are organized around procedures or functions that operate on data.
Object Oriented Programming (OOP) is a modern programming paradigm that organizes programs around
objects rather than procedures.
In OOP, both data and functions are combined together inside objects, which makes programs easier to manage and reuse.
Step 2: Difference between procedural programming and OOP.
Some major differences between Object Oriented Programming and procedural programming are:
• In procedural programming, the focus is on functions or procedures. In OOP, the focus is on objects.
• Procedural programming separates data and functions, while OOP combines them together into objects.
• OOP supports features such as
encapsulation, inheritance, and polymorphism.
• OOP improves code reusability, modularity, and maintainability.
Step 3: Define Class.
A class is a blueprint or template used to create objects in object oriented programming.
It defines the properties (attributes) and behaviors (methods) that objects created from the class will have.
For example, a class named
Student may contain attributes such as name, roll number, and marks.
Example in Python:
class Student:
name = ""
roll = 0
Step 4: Define Object.
An object is an instance of a class. It represents a real-world entity that has attributes and behaviors.
Objects use the structure defined by the class.
Example:
s1 = Student()
Here
s1 is an object of the class
Student.
Step 5: Conclusion.
Thus Object Oriented Programming focuses on objects and classes, making programs more modular, reusable, and easier to maintain compared to procedural programming.