Introduction : Object Oriented Programming Concept

Transcription/प्रतिलिपि
Hello and welcome, today we are going to study about object oriented programming or popularly known as oops.

Object Oriented Programming is a concept of writing a code that has certain elements and have defined behavior. Though, not all programming language supports Object Oriented concept. but it is now one of the most used concept in programming world. Object Oriented Programming can be understood as Programming language which implements Object Oriented concept.


Object Oriented Programming consists of following main elements.They are.
Object,
Class,
Inheritance,
Polymorphism,
Abstraction,
and Encapsulation

Lets take a look in each one of them in detail.

An Object. 
In dictionary terms object means a material thing that can be seen and touched like a real word entity such as pen, chair, table, car etc. In Object-Oriented concept, Object is  Any entity whether physical and logical, that has state or properties for example color, weight, height etc. and behavior or methods like walking, working etc. is known as an object. In Object-Oriented concept, the  methodology or paradigm, is to design a program using classes and objects. This approach simplifies the software development and maintenance by utilizing  the above concepts. 

Here is one example of object, A Car
Car is an object because it is a real world physical entity which has both state 
like color=red, model=porshe, top speed =  etc. and behavior like accelerate, steer, brake and so on.

Next element of Object-Oriented concept is Class. A class is a collection of objects which share same type of behavior and state. like Class of cars. having same type of properties and behavior. A class is a blueprint or prototype or catagory of from which objects are created. Like we say class of objects. The class helps in defining the feature or properties of each car which is an object, to be designed same as all the cars that are created from that blueprint. It is a logical entity.

Now that we have discussed about Class and Objects, lets take a step further and discuss about the other elements of Object-oriented concept which affects object and classes we talked about.

First one is inheritance.
Inheritance is a powerful concept, and is related to real world inheritance, where the child class inherits the state and behavior of its parent class, and add some new states, and or, new behavior of its own.  Inheritance allows programmers to, create classes that are built upon existing classes, to specify a new implementation to maintain the same behaviour (realizing an interface), to reuse code and to independently extend original implementation.  
For example. we have a class of Vehicles which has certain properties of color, weight, number of seats with behavior of accelerate, brake, steer. Lets have another class which inherits from vehicles called Cars. This new child class inherits all the state and behavior from the parent class but may have some additional states like Type of Fuel (Example petrol as not all vechicles run on fuels like bullock cart so this property is unique to cars but not vehicles as it cannot be applied on all the vechicles) and behavior like apply hand brake, Switch Headlights (This behavior is also not applicable to all the vechicles thus it cannot be implemented in vechicles class). 

Though inheritance is very useful in acquiring new state and behavior in the class and retaining the parent class state and behavior at the same time. It is sometimes required to have state and behavior of parent or itself but somewhat different implementation for different types of situation. THis can be achieved with Polymorphism.When same behavior can performed in different ways is polymorphism. Polymorphism means many forms. When child modifies the same behavior for its purpose and not use the same as that of parent is known as method overriding. For example behavior or method braking is to reduce speed of vechicles but child class can override breaking behavior for its implementation. Second type of polymorphism is when a class have more than one methods for the same type of behavior in itself is called method overloading. like separate method for hand brake & main brakes. Both are perform same behavior that is breaking but in different ways

Third concept of OOPs is abstraction. Sometimes it is required to hide certain states and behaviors of the class from the users for security purpose or to avoid bogging them with unnecessary details is called abstraction. it is unnecessary for the user of the car to know how brakes function is applied internally. We can define these states and behavior; private to class which we do not want for others to access. 

Fourth concept of OOPs is encapsulation. Encapsulation defines the concept of capsuling or getting all the state and behavior of the class at one place like a capsule and not defining them at random place in program.


Object-oriented programming is a powerful concept on which most of the modern programming languages implemented on. 


Comments

Popular posts from this blog

Tenalirama: Man who bring kingdom to its knees with rice and chessboard !

DFC_DOCBROKER_EXCLUDED: Primary Docbroker Blacklisted

Enabling Mouse Cursor Recording In OBS