Introduction of OOP
OOPs is a programming language Concept that stands for object-oriented programming. Object-oriented programming System(OOPs) is a programming concept of “objects” containing data and functions to operate on that data or implement the logic.
The developer’s primary purpose is to increase the flexibility and maintainability of the application they are developing. OOPs helps in making the code looks smaller and writing in a manner that can be reusable code. Object-oriented programming System(OOPs) helps developers to bring the data and the functions under one wrapper (for example a class). Then make use of another OOPS concept “Objects” to access the data and functions inside this class. Objects are the whole and sole controllers in OOPs.
Python is Object-oriented programming which means it is different from Procedural programming. Let us see how an OOPs programming language is different from Procedural Oriented Programming.
|Object-Oriented Programming (OOP)||Procedural-Oriented Programming (Pop)|
|1.||OOPs is a bottom-up approach.||Pop is a top-down approach.|
|2.||The program is divided into objects.||The program is divided into functions.|
|3.||Access modifiers like ‘public’, private’.||Doesn’t use Access modifiers. protected’ are available for data & functions|
|4.||OOPs is more secure and modular.||Pop is less secure & traditional.|
|5.||The object can move freely within member functions.||Data can move freely from function to function within programs|
|6||OOPs, support inheritance.||Pop does not support inheritance|
Is Python fully object oriented?
Python supports most of the concepts that bring it to the “objected-oriented” programming language category. But Python misses out on some minor concepts like strong encapsulation support. What does that mean?? Let us understand this: Python has the support for access specifiers, But Python doesn’t support access specifiers like “private”.Hence it is true to some extent that Python is not 100% object-oriented.
OOPs in Python supports the following concepts:
Class: A user-defined blueprint of an object that defines a set of attributes, data variables & methods that the object of the class will hold.
Object: An Object is a unique instance of a class that defines its holding data, methods & attributes. An object comprises all data members, attributes, and methods that get defined while defining the class.
Method or Functions: These are just the function or methods that come in a class definition. To implement any functionality a class uses these methods and functions. These functions and methods can be called by using the class objects.
Inheritance: Inheritance is one of the most interesting concepts of OOPs. This is used to share the characteristics of a class with other classes that are derived from it. This includes the concept of Base class and Derived class. The base class is a kind of parent class of a Derived class.
Encapsulation: Encapsulation is the wrapping of data inside an Object. A class can have different types of data variables and this makes class a kind of user-defined data structure. Then all this data gets encapsulated in an object which keeps this data intact and reusable in big applications.
Data-abstraction: Data abstraction means hiding the actual implementation and only exposing the interfaces to access that logic that is hidden inside. Python implements Data abstraction with the help of classes where classes hold all the functionality in them and it allows the outside world to access that functionality with the help of objects.
Polymorphism: Polymorphism means different versions of functions. This is kind of using the function template with different data types as return types, arguments. This can be done statically or dynamically at run time.
Object-Oriented Programming methodologies
Object-Oriented Programming methodologies make use of the Objects to implement the OOPs concepts in Real-world applications. The main concept is class, which is kind of a blueprint of the Objects that it is going to help us create. The Objects are further used to implement the other OOPs concepts.
With the help of classes and objects we can implement the below concepts in our applications.
All these concepts makes use of classes, data of classes and the Objects of those classes.