Introduction to Object-Oriented Programming:- OOP is a programming paradigm in which you program using objects to represent things you are programming about (sometimes real-world things). These objects could be data structures. The objects hold data about them in attributes. The attributes in the objects are manipulated through methods or functions that are given to the object.
Basic OOP Concepts:
If you are new to OOP languages, you will need to know a few basics before you can get started with code.
Abstraction: The process of picking out (abstracting) common features of objects and procedures.
Class: A category of objects. The class defines all the common properties of the different objects that belong to it.
Encapsulation: The process of combining elements to create a new entity. A procedure is a type of encapsulation because it combines a series of computer instructions.
Information hiding: The process of hiding details of an object or function. Information hiding is a powerful programming technique because it reduces complexity.
Inheritance: a feature that represents the “is a” relationship between different classes.
Interface: the languages and codes that the applications use to communicate with each other and with the hardware.
Messaging: Message passing is a form of communication used in parallel programming and object-oriented programming.
Object: a self-contained entity that consists of both data and procedures to manipulate the data.
Polymorphism: A programming language’s ability to process objects differently depending on their data type or class.
Procedure: a section of a program that performs a specific task.
Advantages of Object-Oriented Programming
One of the principal advantages of object-oriented programming techniques over procedural programming techniques is that they enable programmers to create modules that do not need to be changed when a new type of object is added. A programmer can simply create a new object that inherits many of its features from existing objects. This makes OOP easier to modify.
Object-Oriented Programming vs Functional Programming
In OOP, you store the data in attributes of objects and have functions that work for that object and do the manipulation.
In functional programming, we view everything as data transformation. Data is not stored in objects, it is transformed by creating new versions of that data and manipulating it using one of the many functions.
OOP says that bringing together data and its behavior in a single location makes it easier to understand how a program works.
FP says that data and behavior are distinctively different things and should be kept separate for clarity.