OOPs Concepts in Python
Class
Objects
Polymorphism
Encapsulation
Inheritance
Data Abstraction
Class
Objects
Polymorphism
Encapsulation
Inheritance
Data Abstraction
In object-oriented programming (OOP), objects are the first thing you think about when making a program, and they are also the units of code that come out of the process. In between, each object is turned into a generic class of object, and even more, generic classes are made so that objects can share models and use the class definitions in their code. Each object is an instance of a certain class or subclass. Each class has its own methods or procedures and data variables. An object is the part of the computer that does the work.
All things have three basic qualities: their identity, their state, and how they act. To understand how objects and object-oriented logic work, you must understand these properties.
Identity means that each object has a unique identifier that can be used to tell it apart from other objects. The name, or identity, of each object, is unique and different from those of other objects.
The state is a term for the things that an object has. For instance, the values of the object's variables hold data that can be added, changed, or removed. Behavior is a term for what an object can do. For example, a software function can be done by having one object respond to another object. Some examples of things in programming that can be called "objects" are:
Variables hold values that can be changed;Â
Data structures are special formats used to organize and process data;
Functions are named procedures that do a specific task, and methods are programmed procedures that are defined as parts of a parent class and are included in any instance of that class.
Objects can do things and also be affected by other things. For example, a function or method object can be told to change the contents of a data structure or variable object.
Some of the most common languages that are considered to be object-oriented currently in use include the following:
Non-OOP languages include the following:
Most modern programming languages now support some or all of the rules of object-oriented programming, so it is common to use objects in programming. Some of the most important reasons why programmers should use objects are:
Using objects makes it easier to reuse code. Objects can be used as they are or with small changes to improve or change how they work.
When objects are being used and a problem with the code comes up, debugging is easier. Developers can find the object that is causing the problem without having to look at the whole codebase. Debugging is made easier because a hard-to-work-with object can be swapped out for a simpler one.
Objects can be used without giving away information about how they work.
Objects that are modular can be made, changed, and passed around easily.
That doesn't mean that there are no bad things about programming with objects. Some of the problems with programming with objects are the following:
OOP ideas can be hard to understand, and learning to program with objects can be harder than learning to program with languages that use procedures.
Procedure-based programs can be a lot smaller than OOP programs.
Programs written in procedural programming languages can run faster than programs written in OOP languages.
For simple programs, the differences between programming languages may not matter as much, but for more complicated projects, one programming framework may be better than another.
Kinds of Objects
Objects can be put into groups based on what they are used for or how they function. The following are some of the most common types of objects:
Function objects have one function and are used in the same way as functions in an operating system or programming language.
Objects that can't be changed can't be changed after they've been made. The object's data and state do not change when functions are used.
Objects that are containers can hold other objects. The purpose of factory objects is to make other objects.
Anything else!!??