1. The concept of OOP in Python

  • Object-oriented programming, or OOP, is a programming paradigm that allows programs to be structured so that properties and behaviors are grouped into separate objects.
  • For example, an object can represent a person with a name, age, address, etc., with behaviors such as walking, talking, breathing, and running.
  • In other words, object-oriented programming is an approach to modeling concrete real-world elements such as cars, as well as relationships between entities such as companies and employees, students and teachers, etc. OOP modeling models real entities as software objects that have certain data associated with them and can perform certain functions.


Object-oriented programming is a type of programming based on the creation of classes and objects through a method called instantiation. A class is a prototype (model) coded in a programming language whose purpose is to create objects endowed with a set of methods and attributes that characterize any object of the class. Attributes are data types (class variables and instance variables) and methods, accessible via dot concatenation. In object-oriented programming, the declaration of a class groups together methods and properties (attributes) common to a set of objects. So we could say that a class represents a category of objects. It also appears as a factory for creating objects with a set of common attributes and methods.
Since its inception, Python has been an object-oriented programming language. For this reason, creating and using classes and objects in Python is a fairly straightforward operation. This course will help you learn step by step the use of object-oriented programming in Python.

2. OOP Terminology

  1. Class: abstract code model that represents and characterizes a category of objects having common properties (attributes and methods). Creating an object from a class is called instantiation. The object created from a class is called an instance or instance object.
  2. Class Variable: variable shared by all instances of a class. Class variables are defined inside a class but outside any method of the class. Class variables are not used as often as instance variables.
  3. Data member: a class variable or instance variable that contains data associated with a class and its objects.
  4. Function overloading: assigning multiple behaviors to a particular function. The operation performed varies depending on the types of objects or arguments involved.
  5. Instance variable: variable defined in a method and belonging only to the current instance of a class.
  6. Inheritance: transferring characteristics of a class to other child classes derived from it.
  7. Instance: an object created from a certain class.
  8. Instantiation: creating an instance of a class.
  9. Method: a particular type of function defined in a class definition.
  10. Object: a single instance of a data structure defined by its class. An object includes both data members (class variables and instance variables) and methods.
  11. Operator Overload: assignment of multiple functions to a particular operator.

3. Benefits of OOP

  • We can build the programs from standard work modules that communicate with each other, rather than having to start writing the code from scratch, saving development time and increasing productivity.
  • The OOP programming pradigm allows the program to be broken down into bit-sized problems that can be solved easily (one object at a time).
  • The OOP programming pradigm promises higher programmer productivity, better software quality, and lower maintenance costs.
  • OOP systems can be easily upgraded from small to large systems.
  • It is possible for several instances of objects to coexist without any interference,
  • It is very easy to partition work in an object-based project.
  • It is possible to map objects from the problem domain to those of the program.
  • The principle of data hiding helps the programmer to create secure programs that cannot be invaded by code in other parts of the program.
  • By using inheritance, we can eliminate redundant code and extend the use of existing classes.
  • Messaging techniques are used for communication between objects, which greatly simplifies interface descriptions with external systems.
  • The data-centric design approach allows us to capture more details of the model in an implementable form.

 

Younes Derfoufi
for-beginner.net

Leave a Reply