Object-Oriented Programming Approach
Object-oriented programming can be defined as a programming model which is based upon the concept of objects. Objects contain data in the form of attributes and code in the form of methods. In object-oriented programming, computer programs are designed using the concept of objects that interact with the real world. Object-oriented programming languages are various but the most popular ones are class-based, meaning that objects are instances of classes, which also determine their types
Ex: C++,Java,C#
Object Oriented Programming concepts
· Classes
· Objects
· Data abstraction
· Data encapsulation
· Inheritance
· Polymorphism
· Dynamic binding and
message passing.
Classes and Objects: Classes in object programming languages are similar to the blueprint which has the data members and the member functions. Objects are basically the instances of the classes.
Ex:
A class named bicycle has its data members like cost, weight and
functions like braking (), pedaling () etc.
Trek is the object for the class bicycle. Trek can use all the data
members and the member functions that are the part of the bicycle class
class bicyce
{
float cost;
float weight;
string brand;
void function
breaking(){}
void function
pedaling(){}
}
Data Abstraction: Data abstraction is a concept where only the essential data is shown, and the irrelevant information is hidden from the user. For example, when an e-mail is sent to someone, the system shows the message “E-mail sent” and it does not show all the internal operations that happen while sending the mail.
Data Encapsulation: The process of wrapping up of the entire set of the data members and
member function into a single unit is called as encapsulation. Encapsulation concepts are useful in
object-oriented programming to avoid direct access to the data.
Inheritance: Inheritance is a very important concept of object-oriented programming where the derived class inherits the properties of the base class just like how the child inherits the properties of its parent.
Polymorphism: Polymorphism is the ability to take more than one form. By using polymorphism, it is possible to make the object to behave differently in various situations. Polymorphism is classified into two types. They are runtime and compile time polymorphisms.
Dynamic Binding: Dynamic binding is a concept of the object-oriented programming. In dynamic binding the set of code that is executed in reference to the function is determined only at the run time. It is also called as run time binding or late binding
Message: Objects communicate in OOPS programming language communicate among themselves by receiving and sending information among themselves. A message is sent between the objects by mentioning the object’s name and the function’s name. Message passing invokes the function of the receiving object to get the intended result.
Advantages
· Faster Development: Since object-oriented
programming has the feature of reusability it makes easier to develop the codes
very faster. Object-oriented programming languages are equipped with many libraries of objects. The codes
that are developed for one project will be useful for the other projects also
Improvements in the software productivity:
Disadvantages
· Cannot be opted for all
types of problems: There are many types of problems that a programmer can solve. Those
problems may involve programming styles focusing on logics, programming styles
focusing on procedures, programming styles focusing on the processing. So,
object-oriented programming cannot solve all the types of problems.
Comments
Post a Comment