Sunday 6 December 2020

OBJECT ORIENTED PROGRAMMING(OOP)


Mainly programming languages are divide to two programming paradigms there are,

  • Imperative 
  • Declarative

Object Oriented programming is a example for Imperative programming paradigm an object is a particular instance of a class and consists, essentially of data which defines its characteristics and current status together with procedures, or 'methods' ,which operate on the object.


Principles of object-oriented programming

These are the four main principles of the object-oriented programming paradigm.

1.Polymorphism.


It describes the concept that different classes can be used with the same interface and we can overload a method with different sets of parameters.

 



2.Inheritance.

Inheritance is a mechanism in which one class acquires the property of another class. For example, a child inherits the traits of his/her parents. With inheritance, we can reuse the fields and methods of the existing class.

 



3.Abstraction

Abstraction means displaying only essential information and hiding the details. Data abstraction refers to providing only essential information about the data to the outside world, hiding the background details or implementation.

 

 

Imagine a guy want to save csv file on his database so he is coding "database.store(csv)" then he want save video file to his database then he have to type his code like "database.store(video)" so that guy have to type his code again to again but (OOP)abstraction method not like that .In abstraction we not care file type and code like above image. 

4.Encapsulation

Encapsulation is an Object Oriented Programming concept that binds together the data and functions that manipulate the data, and that keeps both safe from outside interference and misuse.

 


If we look above image we can see student's class and teacher's class and plenty of words, I divided those words to these two classes and you can see teachers name and students array belong to teacher's class like wise student name and teacher belong to student's classes that way we can use in programing that's called encapsulation ..

No comments:

Post a Comment