Welcome to deBUG.to Community where you can ask questions and receive answers from Microsoft MVPs and other experts in our community.
3 like 0 dislike
1.7k views
in Blog Post by 6 8 12
edited by

In this article, you will learn What does Object-Oriented Programming mean?. Also, you will be introduced to Building blocks / or structures of OOP. Lastly, the four fundamental concepts and Benefits of OOP will be explained.

What Is Object-Oriented Programming?

  • Object-oriented programming (OOP) is a programming paradigm that relies on the concept of classes and objects.
  • It is used to structure a software program into simple, reusable pieces of code blueprints (usually called classes), which are used to create individual instances of objects.

Introduction to OOP

What Is Structured Programming?

Structured Programming: Techniques that impose a logical structure to the coding of a program in order to make it easy to follow. Large routines are broken down into small modules that have to be methodically and carefully nested within each other. 

In the below table we will list the main differences between structured programming and object-oriented programming 

Structured Programming vs Object-Oriented Programming 

 Structured Programming

 Object-Oriented Programming 

Structured Programming is designed which focus on process/ logical structure and then data required for that process. 

 Object-Oriented Programming is designed which focus on data.

 Structured Programming is also known as Modular Programming and is a subset of procedural programming language

 Object-Oriented Programming supports inheritance,  encapsulation, abstraction, polymorphism, etc.

 In Structured Programming, Programs are divided into small self-contained functions.

 In Object-Oriented Programming, Programs are divided into small entities called objects.

 Structured Programming is less secure as there is no way of data hiding.

 Object-Oriented Programming is more secure as having a data hiding feature.

 Structured Programming can solve moderately complex programs.

 Object-Oriented Programming can solve any complex program.

 Structured Programming provides less reusability, more function dependency.

 Object-Oriented Programming provides more reusability, less function dependency.

 Less abstraction and less flexibility.

 More abstraction and more flexibility

 programming languages: C, Pascal, Basic 

 programming languages: C++, Java, and Python.


Object-oriented programming structure 

The structure, or building blocks, of object-oriented programming, include the following:

  • Classes.
  • Objects.
  • Methods.
  • Attributes.

What are classes? 

Classes are user-defined data types that act as the blueprint for individual objects, attributes, and methods.

What are objects? 

Objects are instances of a class created with specifically defined data. Objects can correspond to real-world objects or an abstract entity. When class is defined initially, the description is the only object that is defined.

What are methods? 

Methods are functions that are defined inside a class that describe the behaviors of an object. Each method contained in class definitions starts with a reference to an instance object. Additionally, the subroutines contained in an object are called instance methods. Programmers use methods for reusability or keeping functionality encapsulated inside one object at a time.

What are attributes? 

Attributes are defined in the class template and represent the state of an object. Objects will have data stored in the attributes field. Class attributes belong to the class itself.


Object-oriented programming concepts

There are four fundamental concepts of Object-oriented programming include following: 

  1. Inheritance
  2. Encapsulation
  3. Polymorphism
  4. Abstraction

What's Inheritance?

Inheritance is the procedure in which one class inherits the attributes and methods of another class. 

A real-life example of Inheritance:
A child inherits the features of its parents such as the beauty of the mother and the intelligence of the father as shown in the below figure.

 

What's Encapsulation?

Encapsulation is a way to ensure security. Basically, refers to the bundling of data, along with the methods that operate on that data, into a single unit.

A real-life example of Encapsulation:
An organization is consists of several departments like the production department, purchase department, sales department, and Accounts department. It combines all these departments together and had formed the organization.

What's Polymorphism?

Polymorphism refers to the functions having the same names but carrying different functionalities.

A real-life example of polymorphism:
Man is only one, but he takes multiple roles like - he is a dad to his child, he is an employee, a salesperson, and many more as shown in the below figure.

What's Abstraction?

Abstraction hides the internal details or implementations of a function and shows its functionalities only.

A real-life example of abstraction:
ATM Machine. All are performing operations on the ATM machine like cash withdrawal, money transfer, retrieve mini-statement…etc. but we can't know internal details about ATM.

Benefits of OOP

In general, OOP reduces and manages the complexity of the program.

Here are the main benefits concepts of OOP:

  1. Modularity. Encapsulation enables objects to be self-contained, making troubleshooting and collaborative development easier.
  2. Reusability. Code can be reused through inheritance, meaning a team does not have to write the same code multiple times.
  3. Easily upgradable and scalable. Programmers can implement system functionalities independently.
  4. Security. Using encapsulation and abstraction, complex code is hidden, software maintenance is easier and internet protocols are protected.
  5. Flexibility. Polymorphism enables a single function to adapt to the class it is placed in. Different objects can also pass through the same interface.

Conclusion

Object-oriented programming requires thinking about the structure of the program and planning it from the beginning. This includes breaking down requirements into simple, reusable classes that are used to create instances of objects.

References:

by 8 8 10
0 0
Great Article, keep it up.

If you don’t ask, the answer is always NO!
...