Object-Oriented Programming
Object-oriented programming is a paradigm where programs are defined in terms of "object classes" that communicate with each other by sending messages. It is an evolution of the paradigms of procedural, structured, and modular programming, and is implemented in languages such as Java, Python, or C ++.
Classes define the behavior and available state that is specified in objects, and allow a more direct representation of the concepts necessary for modeling a problem, allowing the user to define new types.
Objects are characterized by:
- An identity that differentiates them from each other
- Defining their behavior through methods
- Defining their state through properties and attributes
Classes allow grouping in a new type of data and the functionalities associated with objects, favoring separation between the details of the implementation of the essential properties for its use. In this way, the goal is to not show more than the relevant information, hiding the state and the internal methods of the class, it is known as "encapsulation," and it is a principle inherited from modular programming.
An important aspect in the use of classes is that they are not manipulated directly, but serve to define new types. A class defines properties and behaviors for objects (instances of a class). A class acts as a template for a set of objects, which are said to belong to the class.
The most important techniques used in object-oriented programming are:
- Abstraction: Objects can perform tasks, interact with other objects, or modify and report their status without the need to communicate how those actions are performed.
- Encapsulation: Objects prevent the modification of their internal state or a call to internal methods by other objects, and are only related through a clear interface that defines how they relate to other objects.
- Polymorphism: Different behaviors may be associated with the same name.
- Inheritance: Objects are related to others by establishing hierarchies, and it is possible that some objects inherit the properties and methods of other objects, extending their behavior and/or specializing. Objects are grouped like this in classes that form hierarchies.