What Is Object-Oriented Programming?
Alan Kay coined the term “Object-Oriented Programming” (OOP), also known as oops concepts in Python, in 1966 while in graduate school. Simula was the first programming language to include features of object-oriented programming. It was created in 1967 to create simulation programs in which the most important information was referred to as objects.
- Object-oriented Programming (OOPs) is a programming paradigm in Python that employs objects and classes.
- It aims to incorporate real-world entities such as inheritance, polymorphisms, encapsulation, and so on into programming
- .An object is a collection of interconnected variables and functions. These variables are frequently referred to as object properties, and functions are referred to as object behavior.
- The goal of Object-Oriented Programming (OOP) is to create “objects.”
Concepts of OOP:
Object-Oriented Programming methodologies deal with the following concepts.
Before going into the details of the above-mentioned mythologies, let us take a look at other basic concepts.
A class is defined as a group of items. It is a logical entity with a few distinct characteristics and methods. For example, if you have a Student class, it should have attributes and methods such as name, class, roll_num, marks, percent, grade, and so on.
An object is a class instance. It is a state and behavior entity. Simply put, it is a class instance that has data access. It could be anything in real life, such as a mouse, keyboard, chair, table, pen, and so on. Python considers everything to be an object, and the majority of objects have attributes and methods.
An object is made up of:
- The attributes of an object represent its state. It also reflects an object’s properties.
- Behavior is represented by an object’s methods. It also reflects an object’s reaction to other objects.
- Identity: It gives an object a unique name and allows one object to interact with other objects.
The procedure by which one class inherits the attributes and methods of another class is known as inheritance. The Parent class is the one whose properties and methods are inherited. The Child class is the one that inherits the parent class’s properties.
Polymorphism is made up of the words “poly” and “morphs.” Poly stands for many, and morph stands for shape. Polymorphism denotes the presence of multiple forms. It refers to functions with the same names but different functionalities in OOP. For example, if we need to determine whether a given species of animal is carnivorous or not, we can use polymorphism to do so with a single function.
Encapsulation protects code and data from accidental modification by wrapping them together within a single unit. Using OOP, we can restrict access to methods and variables in Python. The process of preventing direct data modification is known as encapsulation. In Python, the underscore prefix is used to denote private attributes, such as single_ or double__.
A class is an example of encapsulation as it encapsulates all the data that is member functions, variables, etc.
It shields the user from unnecessary code details. Also, when we do not want to reveal sensitive parts of our code implementation, data abstraction comes into play.
Data abstraction in Python is accomplished by creating abstract classes. Because data abstraction is accomplished through encapsulation, the two terms are nearly synonymous.
Note: also read about User-Defined Functions in Python
Please follow me to read my latest post on programming and technology if you like my post.
Staying up to the mark is what defines me. Hi all! I’m Rabecca Fatima a keen learner, great enthusiast, ready to take new challenges as stepping stones towards flying colors.