DEV Community

Saurav Ghimire
Saurav Ghimire

Posted on

OOP and it's use cases

OOP is an abbreviation for the word "Object oriented programming".
it is based on the concept of "objects", which basically contains data and code:
data :-> data is in the form of fields (such as attributes and properties)
code:-> in the form of procedures/processes also known as methods.

a feature of objects is object's own procedures which can access and often modify the data fields or itself(objects have a notion of "this" or "self").
The four basics of object oriented programming are:
1.Encapsulation
2.Abstraction
3.Inheritance
4.Polymorphism

1.Encapsulation
->The word 'encapsulate' means to enclose something. just like a pill "encapsulates" or contains the medication inside of its coating. In similar way, in OOP: by forming a protective barrier around information contained within a class from the rest of the code.
what is encapsulation used for?
->Object oriented programming uses this aspect for hiding sensitive data and displaying only that particular data that is necessary for the user at that particular time of work.
Encapsulation can work with a property known as "Access Modifiers". Access modifiers are there to modify one's access towards certain data or method within the class, outside the class, within derived the class etc.
These modifiers are mainly private, public and protected access modifiers and are specified along with class specification.

Eg. of Encapsulation
Class Car{
private: Engine E; //private data
public:
bool unlock: //public data
.
.
.
car(){ // public method
}
}
encapsulation is a good coding practice and it increases the security of your data.

2.Abstraction
->Abstraction is an extension of encapsulation. It is the process of selecting data from a larger pool to show only the relevant details to the object. Suppose you want to create a dating application and you are asked to collect all the information about your users. You might receive the following data from your user: Full name, address, phone number, favorite food, favorite movie, hobbies, tax information, social security number, credit score. This amount of data is great however not all of it is required to create a dating profile. You only need to select the information that is pertinent to your dating application from that pool. Data like Full name, favorite food, favorite movie, and hobbies make sense for a dating application. The process of fetching/removing/selecting the user information from a larger pool is referred to as Abstraction. One of the advantages of Abstraction is being able to apply the same information you used for the dating application to other applications with little or no modification.

  1. Inheritance
    Inheritance is the ability of one object to acquire some/all properties of another object. For example, a child inherits the traits of his/her parents. With inheritance, reusability is a major advantage. You can reuse the fields and methods of the existing class. In Java, there are various types of inheritances: single, multiple, multilevel, hierarchical, and hybrid. For example, Apple is a fruit so assume that we have a class Fruit and a subclass of it named Apple. Our Apple acquires the properties of the Fruit class. Other classifications could be grape, pear, and mango, etc. Fruit defines a class of foods that are mature ovaries of a plant, fleshy, contains a large seed within or numerous tiny seeds. Apple the sub-class acquires these properties from Fruit and has some unique properties, which are different from other sub-classes of Fruit such as red, round, depression at the top.

  2. Polymorphism
    Polymorphism gives us a way to use a class exactly like its parent so there is no confusion with mixing types. This being said, each child sub-class keeps its own functions/methods as they are. If we had a superclass called Mammal that has a method called mammalSound(). The sub-classes of Mammals could be Dogs, whales, elephants, and horses. Each of these would have their own iteration of a mammal sound (dog-barks, whale-clicks).

Use case of Object oriented Programming:

  1. Client-Server Systems

Object-oriented client-server systems provide the IT infrastructure, creating Object-Oriented Client-Server Internet (OCSI) applications. Here, infrastructure refers to operating systems, networks, and hardware. OSCI consist of three major technologies:

The Client Server
Object-Oriented Programming
The Internet

  1. Object-Oriented Databases

They are also called Object Database Management Systems (ODBMS). These databases store objects instead of data, such as real numbers and integers. Objects consist of the following:

Attributes: Attributes are data that define the traits of an object. This data can be as simple as integers and real numbers. It can also be a reference to a complex object.

Methods: They define the behavior and are also called functions or procedures.

  1. Object-Oriented Databases

These databases try to maintain a direct correspondence between the real-world and database objects in order to let the object retain its identity and integrity. They can then be identified and operated upon.

  1. Real-Time System Design

Real-time systems inherent complexities that make it difficult to build them. Object-oriented techniques make it easier to handle those complexities. These techniques present ways of dealing with these complexities by providing an integrated framework, which includes schedulability analysis and behavioral specifications.

  1. Simulation and Modeling System

It’s difficult to model complex systems due to the varying specification of variables. These are prevalent in medicine and in other areas of natural science, such as ecology, zoology, and agronomic systems. Simulating complex systems requires modeling and understanding interactions explicitly. Object-oriented programming provides an alternative approach for simplifying these complex modeling systems.

  1. Hypertext and Hypermedia

OOP also helps in laying out a framework for hypertext. Basically, hypertext is similar to regular text, as it can be stored, searched, and edited easily. The only difference is that hypertext is text with pointers to other text as well.

Hypermedia, on the other hand, is a superset of hypertext. Documents having hypermedia not only contain links to other pieces of text and information but also to numerous other forms of media, ranging from images to sound.

  1. Neural Networking and Parallel Programming

It addresses the problem of prediction and approximation of complex time-varying systems. Firstly, the entire time-varying process is split into several time intervals or slots. Then, neural networks are developed in a particular time interval to disperse the load of various networks. OOP simplifies the entire process by simplifying the approximation and prediction ability of networks.

  1. Office Automation Systems

These include formal as well as informal electronic systems primarily concerned with information sharing and communication to and from people inside and outside the organization. Some examples are:

Email
Word processing
Web calendars
Desktop publishing

  1. CIM/CAD/CAM Systems

OOP can also be used in manufacturing and design applications, as it allows people to reduce the effort involved. For instance, it can be used while designing blueprints and flowcharts. OOP makes it possible for the designers and engineers to produce these flowcharts and blueprints accurately.

  1. AI Expert Systems

These are computer applications that are developed to solve complex problems pertaining to a specific domain, which is at a level far beyond the reach of a human brain.

It has the following characteristics:

Reliable
Highly responsive
Understandable
High-performance

Top comments (0)