What is OOP (Object-Oriented Programming)?

what is oop object oriented programming.
What is OOP (Object-Oriented Programming)

You must have heard of OOP (Object-Oriented Programming). Because most popular programming languages ​​follow the object-oriented programming paradigm. In this article, we will discuss what OOP is and how the concept of OOP is.


What is OOP?

OOP (Object-Oriented Programming) is a programming language paradigm or a special way of designing programs created by Alan Kay. In object-oriented programming, code can be structured as components that can be reused, such as sharing properties or behaviors. The main goal of OOP is to unify data and the functions that operate on them so that no other part of the code can access this data except those functions.


OOP concept

When programming in an object-oriented programming language, you should keep the following four key concepts in mind.

  • Encapsulation - Grouping of functions and related data ( variables ) together into an object to help reduce complexity and allow parts of code to be reused.
  • Abstraction - Show only what is important to reduce the abstraction of changes.
  • Inheritance - Eliminate redundant code by inheriting functions and data from other classes.
  • Polymorphism - Changes how object functions depending on data or classes.


Common OOP Examples

Let's say you are programming a video game in which players control and drive a vehicle. If you use an object-oriented programming language, you can define a class of objects named “vehicles.” This class can contain definitions of qualities and behaviors shared by all vehicles. For example, all vehicles accelerate and decelerate, and consume fuel. In this class definition, you can define methods (similar to functions) called “acceleration” and “deceleration,” and the properties (a type of variable) that are called “fuel,” whose value you can get or set.

Then, you can define a subclass, also called a derived class or child class, which inherits the methods and properties of the "vehicle" class. For example, you can define a subclass called “motorcycle” which has two wheels, and a subclass called “car” which has four wheels. Their shared qualities (acceleration, deceleration, and fuel consumption) are already defined in the “vehicle,” so you don't have to write that down again.

Then, you can instantiate these subclasses to define individually playable vehicles. Each instance of a subclass separates the methods and properties of all parent classes and has its own properties and methods. For example, unique traits might include paint color ("red", "blue", etc.), and price (if the player wishes to purchase it with in-game currency).


Then, when you want to change the code that is specific to motorcycles, you don't need to change the parent class "vehicle". The “vehicle” code has been tested and works well, so modifying your program requires less work. Also, as fewer lines of code are being modified, there is less chance that a bug will be introduced somewhere in the new code. If a bug appears, you don't have to wonder if it's in the "vehicle" code class, because that class is not modified. Therefore software development and maintenance may be more efficient, saving time and effort.


Advantages and Disadvantages of OOP

Object-oriented programming contributes to greater programmer productivity, better software quality, and lower maintenance costs.

Excess

 1. Utilizing inheritance, redundant code is eliminated, and existing classes are extended.

 2. It is easy to maintain and modify existing code because new objects can be created with little difference.

 3. Provide a good framework for code libraries in which the provided software components can be easily adapted and modified by programmers.

 4. Through data hiding, programmers can build secure programs that cannot be attacked by code in other parts of the program.

 5. The system can be easily upgraded from small to large systems.

 6. Code reuse is much easier than conventional programming languages.


Deficiency

 1. Due to the large size of the program the execution speed is slow. Even a lot of coding instructions make program execution slower and its efficiency effect.

2. Object-oriented programming programs are larger in size than traditional procedural programming.

 3. If a programmer does not have enough knowledge and skills about programming, then it becomes difficult for them to code and manage it.

 4. Designing and implementing object-oriented programming concepts correctly is quite complicated and burdensome for programmers.


Example of an Object-Oriented Programming Language

There are many different languages ​​that use object-oriented programming. Among them are:

  * Java developed in 1995 by Sun Microsystems, now Oracle

  * Python was created in 1991 and emphasizes code readability

  * C ++ which features imperative, object-oriented, and generic programming and is an extension of the C programming language

  * Objective-C which adds Smalltalk style messaging to C and is the primary programming language for OSX and iOS.


Summary

So What is OOP? OOP (Object-Oriented Programming) is a programming paradigm or a special way of designing programs. It allows us to think of the data in our programs in terms of real-world objects, with properties and behaviors. There are 4 main principles that make language object-oriented. These are Encapsulation, Abstraction, Inheritance, and Polymorphism. These are also referred to as the four pillars of Object-Oriented Programming.

Hopefully, this article about What is OOP (Object-Oriented Programming) gives you a little insight. Also, read an article about What is OSINT (Open Source Intelligence) that you may need to know. Thank you.

Previous Post Next Post