OOP stands for Object-Oriented Programming.
Procedural programming is about writing procedures or functions that perform operations on the data, while object-oriented programming is about creating objects that contain both data and functions. Object oriented programming languages are various but the most popular ones are class-based.
Languages used in Procedural Programming:
FORTRAN, ALGOL, COBOL, BASIC, Pascal and C.
Languages used in Object Oriented Programming:
Java, C++, C#, Python, PHP, JavaScript, Ruby, Perl, Objective-C, Dart, Swift, Scala.
Example of simple procedural :
var a,b; function getSum(){ return a+b; }
Example of object oriented language:
class sum{ private var a,b; function getSum(){ return a+b; } }
Object-oriented programming has several advantages over procedural programming:
- OOP provides a clear structure for the programs
- Program is divided into small parts called objects.
- Improved software-development productivity
- Improved software maintainability
- Lower cost of development
- OOP is faster and easier to execute
- OOP follows bottom up approach intead of top down approach
- OOP is based on real world
- Adding new data and function is easy.
- OOP has have access specifiers like private, public, protected etc.
- OOP has concept of data hiding, Overloading, Encapsulation, polymorphism, Inheritance, abstract class.
- OOP also has Reusability, dynamic nature ,inter communication within the blocks, multithreading, etc which are missing in procedural language.
What are Classes and Objects ?
There are two two main aspects of object-oriented programming, these are Class and object. The class is a template for the object, and the object is an instance of the class.
Example-1:
Example-2:
Please write comments if you find anything incorrect. A gentle request to share this topic on your social media profile.