Object Oriented Programming Paradigm
OOP is a programming paradigm used for software development. Its basis is modeling objects and relationships in real world. OOP paradigm of our software projects; It makes it more modular, readable, understandable and easy to maintain.
However, those who stepped into the software world late often think that the OOP software paradigm has always existed. However, over time, software paradigms have emerged as a result of various problems, deficiencies and, most importantly, needs.
The complexity and scalability problems that arise in software projects that grow over time have further increased the need for this paradigm. Therefore, Alan Kay developed the “Smaltalk” language to meet these needs and OOP emerged. Later, languages such as C++, Java, Python and C# also adopted this approach, resulting in more manageable, sustainable and sustainable projects in the sector.
Now, let’s take a look at the basics of OOP and what feeds this paradigm that makes our projects more modular. The OOP paradigm has 5 basic pillars:
1- Class and object relationships: Classes are design templates that contain the attributes and methods (behavior) of objects. Objects are instances of these classes. By creating an object of a class, we can access and implement the attributes and methods of that class. Classes and objects make our code more modular and make it easier to share similar features and behaviors.
Benefits of classes and objects:
1 — Classes break code into smaller manageable pieces. Thus, while each class does its own job, the code can be understood more easily and maintained more easily.
2 — Development speed increases as it reduces code repetition.
3 — Prepares the basis for other OOP principles.
2- Encapsulation:
The concept of Encapsulation is used to introduce access control to the object’s data. Access is provided using certain modifiers. Anyone cannot access the data as they wish.
Benefits of Encapsulation:
1 — It is important for data security.
3- Abstraction:
Abstraction is one of the most basic and important concepts of OOP and software engineering. Abstraction is the principle of hiding some details in order to emphasize important features in complex systems. In this way, it becomes easier to see the big picture of the project and the operation becomes simpler and more understandable.
Benefits of Abstarction:
1 — Reducing complexity: A system with high complexity can be represented using a high-level abstraction.
2 — Reusability: Abstraction of base classes or data types increases the reusability of the code. This speeds up the implementation process and reduces code repetition.
3 — Hiding details: Unnecessary details are abstracted to focus on what is what. In other words, systems, objects, classes exist as far as we can see.
Example of Abstraction: Database objects represent data stored in the database. We can access data using the functions offered by the database object, but we have no knowledge of how it is stored and managed.
4- Inheritance:
Inheritance is defined as a class inheriting features and behaviors from another base class. Inheritance represents the parent-child relationship between classes.
Benefits of inheritance:
1 — Increases code reusability and prevents code duplication.
2 — We create general classes by bringing similar classes together through inheritance. In this way, it offers a high-level and abstract perspective.
3 — Derived classes can extend the features of base classes and add features and behaviors. This allows the code to be more flexible and customizable.
4 — Thanks to the hierarchical structure of inheritance, complex systems become more orderly.
5- Polymorphism:
First of all, in order to talk about polymorphism, it is necessary to consider the concept of “override”. Override is when the subclass changes a certain behavior or function of the parent class according to its own needs. Polymorphism also supports and maintains this. It redesigns the content of a method inherited from the superclass according to its own needs and logic.
Benefits of polymorphism:
1 — Enables objects in the same class hierarchy to behave in different ways using the same interface.
2 — Provides flexibility by customizing different objects.
3 — The reusability of the code increases.