Object-Oriented Programming (OOP)

Hello friends, in this article you will get to about object-oriented programming or simply OOP with its features, advantages, and disadvantages as well as application of OOP.
 

Introduction

Object-oriented programming(OOP)  is a programming language model organized around objects rather than “actions” and data rather than logic. Historically, a program has been viewed as a logical procedure that takes input data, processes it, and produces output data. Object-oriented programming attempts to respond to these needs, providing techniques for managing enormous complexity, achieving reuse of software components, and coupling data with the tasks that manipulate the data. The essence of object-oriented programming is to treat data and the procedures that act upon the data as a single “object”, a self-contained entity with an identity and certain characteristics of its own. C++ is the most popular object-oriented programming language but nowadays other popular programming languages like Visual Basic and Java also uses OOP philosophy.
The major motivating factor in the invention of object-oriented is to remove some of the flaws encountered in the procedural-oriented approach. Object-oriented programming treats data as a critical element in program development and does not allow it to flow freely around the system. It ties data more closely to the functions that operate on it and protects it from accidental modifications from outside functions.
Object-oriented programming allows a decomposition of a problem into a number of entities called objects and then builds data and functions around these objects. The data of an object can be accessed only by the functions associated with that object. however, the functions of one object can access the functions of other objects.
Object Oriented Programming (OOP) - Fully Explained - ComputeNepal
Object-oriented programming can be defined as an “Approach that provides a way of modulizing programs by creating partitioned memory area for both data and functions that can be used as templates for creating copies of such modules on demand.” Thus, an object is considered to be a partitioned area of computer memory that stores data and a set of operations the can access that data. Since the memory partitions are independent, the objects can be used in a variety of different programs without modifications.

Features of OOP

a. Class

A Class is a blueprint, or prototype, that defines the variables and the methods common to all objects of a certain kind. Classes are data types based on which objects are created. Thus a class represents a set of individual objects. For example consider we have a class of cars under which Santro, Xing, Alto, and WaganR represent individual objects. In this context, each car object will have its own, Model, Year of Manufacture, Colour, Top speed, Engine Power, etc. Which forms the car class and the associated actions i.e. object functions like start, move, stop from the Methods of the car Class.

b. Objects

Objects are the basic unit of object-oriented programming. They are identified by their unique name. An object represents a particular instance of a class. There can be more than one instance of an object. Each instance of an object can hold its own relevant data. The objects are the self-contained component that contains properties and methods needed to make a certain type of data useful. An object’s properties are what it knows and its methods are what it can do. The project management application mentioned above has a status object, a cost object, and a client object, among others. One property of the status object would be the current status of the project. The status object would have a method that could update that status. The client object’s properties would include all of the important details about the client and its methods would be able to change them. The cost object would have methods necessary to calculate the project’s cost based on hours worked, hourly rate, materials cost, and fees.

c. Inheritance

Inheritance is the process by which objects in one class acquire the properties of objects of another class. It supports the concept of hierarchical classification. In other words, we may have common features or characteristics that may be needed by a number of classes. So those features can be placed in a common tree class called base class and the other classes which have these characteristics can take the tree class and defines only the new things that they have on their own in their classes. These classes are called derived classes. The main advantage of using this concept of inheritance in object-oriented programming help in reducing the code size.

d. Reusability

This term refers to the ability for multiple programmers to use the same written and debugging existing code. Once a class is completed and tested, it can be distributed for the development of other programs too. The programmer can add new features or make some changes or can derive new classes from the existing class. It saves time and effort for a programmer. In object-oriented programming, the concept of inheritance provides the idea of reusability. The general idea behind reusability is that since there are so many programs being built, there’s bound to be some commonality between the functionality of different applications. Since it takes so much time and effort to build, thoroughly test and then verify any piece of code properly, it makes sense to try and reuse existing code within an application whenever possible. The idea of reusability is not new to object-oriented programming. In fact, talk of reusability has been around for as long as programming has been around, and it has just been taking different forms.

e. Data Abstraction

An abstraction denotes the essential characteristics of object-oriented programming that hides the internal details of the object. It focuses on the outside view of an object, and so serves to separate an object’s essential behavior from its implementation and essential characteristics of some object, relative to the perspective of the viewer. Let’s take the example of a watch. it is constructed from many different parts. The abstraction allows the user to see the time without having detailed knowledge of the complexity of the parts. Thus data abstraction is the process of recognizing and focusing on important characteristics of a situation or object and leaving/ filtering out the unwanted characteristics of that situation or object. Let’s take a person as an example and see how that person is abstracted in various situations.

f. Encapsulation

Data encapsulation is the mechanism that binds code and data it manipulates and keeps both safes from outside interference and misuse. The data are visible only to that particular function, called data hiding. It is a way of organizing data and methods into a structure by concealing the way the object is implemented, i.e. preventing access to data by any means other than those specified. Encapsulation, therefore, guarantees the integrity of the data contained in the object.

g. Polymorphism

The word “polymorphism” is derived from the Greek word “poly-morphos” which means many forms. The different ways of using the same function or operator depending on what they are operating on are called polymorphism. In OOP, polymorphism refers to a programming language’s ability to process objects differently depending on their data type or class. More specifically, it is the ability to redefine methods for derived classes.

Advantages of OOPs

  • high security due to encapsulation and abstraction.
  • Programs are divided into objects which makes it easier for the programmer.
  • Upgrading and maintenance of existing code can be easily managed.
  • Models real-world systems perfectly.
  • A base class can be extended to the derived class by adding the required features.

Disadvantages of OOPs

  • Requires mastery in software engineering and programming methodology.
  • Benefits only in long run while managing large software projects.
  • Compiler and runtime overhead.
  • The message passing between many objects in a complex application can be difficult to trace and debug.

Application of OOP

Applications of OOPs are gaining importance. There is a lot of excitement and interest among software developers in using OOPs. The richness of the OOP environment will enable the software industry to improve not only the quality of the software systems but also their productivity. Object-oriented technology is certainly changing the way software engineers think, analyze, design, and implement systems.
The most popular application using object-oriented programming is the interface designing for window-based systems. Real systems are more complex and contain many objects with a large number of attributes and methods of complex nature. OOP is useful in such cases because it can simplify a complex problem.

Areas of Application of OOP concept

The promising areas include the following,
  • Real-Time Systems design
  • Simulation and Modeling system
  • Object-Oriented Database
  • Object-Oriented Distributed Database
  • Client-Server System
  • Hypertext, hypermedia
  • Neural Networking and Parallel Programming
  • Decision Support and Office Automation Systems
  • CIM/ CAD/ CAM systems
  • AI and Expert Systems

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *