We use cookies to give you the best experience possible. By continuing we’ll assume you’re on board with our cookie policy

Object Oriented Programming ( OOP ) , is a term used to depict an application that is composed of multiple objects connected to each other. Programing languagesA were merely a group of maps or instructions earlier. Using the construct of OOP, every object can manage informations and execute other actions. The objects will all move as independent units possessing their ain actions and will be responsible for transporting out procedures. The objects are non dependent on each other and hence Object Oriented Programming is more flexible than older scheduling methods.

The best essay writers are ready to impress your teacher.
Make an order now!


Proceed

Programing Patterns and Techniques

Here, we shall be discoursing the scheduling techniques which are in general categorised as follow:

GET A BETTER ESSAY OUR TEAM IS READY TO WRITE
YOUR ESSAY ON
Object Oriented Programming Computer Science Essay JUST FROM $13/PAGE

Unstructured scheduling

Procedural scheduling

Modular scheduling

Object Oriented Programming

Let us now see what these mean in a programming linguistic communication.

Unstructured Programing

Novices start programming by composing simple plans which contain merely of a chief ( ) map, where chief Acts of the Apostless as a sequence of bids or compound statements which modify informations throughout the plan. The undermentioned figure shows the lineation.

Plan

chief ( ) map

{ bids }

The unstructured scheduling technique proves disadvantageous once the plan becomes immense.

Procedural Programing

This form enables us to unite returning sequences into a individual topographic point. A process initiates the process. After the sequence is processed, the flow of control moves right after the place from where its the chief plan process.

Main

Procedure

End

Procedures get executed after treating flow of controls returns where it was called from. Including parametric quantities every bit good as processs of processs ( known as sub-procedures ) plans can be written in structured manner doing them less prone to mistakes. The plan can be viewed as a sequence of process calls. The chief ( ) map is responsible to direct informations to the single demands and the information is processed by the processs where the ensuing informations is presented.

chief ( )

procedure1 procedure2 procedure3

The chief plan co-ordinates connexions to the processs and sends appropriate informations to it. Overall consequence of this is, we have a individual plan which is sectioned into different pieces named as procedures_ To enable use of general processs or groups of processs. But what if excessively many processs pile up? For that ground, we have modular scheduling which allows grouping of processs into faculties as given below.

Modular Programing

Using modular scheduling, processs with similar/common functionalities are grouped together into faculties defined for each group. This makes the plan contain more figure of parts and hence its divided into little subdivisions doing it easy to interact. Besides the whole plan is made by blocks of codifications

chief ( )

Module 1 Module 2

Procedures Procedures

The chief plan calls the processs in separate faculties and custodies over appropriate informations as parametric quantities. Each faculty can hold its alone informations. This allows each faculty to possess an internal province which is modified by calls to processs of the peculiar faculty, although there is merely one province per faculty and each faculty exists at most one time in the whole plan.

Object Oriented Programming

Object Oriented Programming ( OOP ) is the advanced technique which overcomes the disadvantages of the other scheduling forms and besides propagate their advantageous characteristics. The below illustration demo how OOP handles a plan

Object B

{ Datas }

Object C

{ Datas }

Object A

{ Datas } Program

We have a web of interacting objects inside a individual plan, which means that any object can interoperate with any other object during executing which is in contrast with the other forms we saw earlier

Objects of the plan interact by directing informations to each other. See the multiple lists to be handled. The job here with modular scheduling is that we should explicitly make and destruct your list animal trainers. Then we use the processs of the faculty to modify each grip. Unlike OOP, we would hold as many list objects as needed. Alternatively of naming a process which we must supply with the right list grip, we would straight direct a message to the list object in inquiry. Roughly speech production, each object implements its ain faculty and is responsible to initialise and destruct itself. There no longer exists the demand to explicitly name a creative activity or expiration of a process.

ABSTRACT DATA TYPE

In this subdivision allow us see abstract informations types as a basic construct for implementing Object Oriented Programming

Let us take an illustration to explicate this. See a auto fabrication mill keeping the records on auto assemblies. Each auto has its ain alone characteristics. Each of these characteristics are recorded in a file with the following inside informations.

Name of Part:

Property:

Built-in Role:

Not all of these belongingss are necessary to work out the jobs which arise while covering with the parts. Consequently we create a theoretical account of an parts of autos for the job. This theoretical account merely implies belongingss which are needed for the demands of the fix.

Abstract Data Types

The illustration above shows that with abstraction we create a defined entity which can be handled. The information construction can merely be accessed with defined undertakings. This set of operations is called interface and is exported by the entity. An entity with the

belongingss merely described is called an abstract informations type.

Properties of Abstract Data types

Export type of value.

Export a set of operations called as interface.

Operationss of the interface are the one and merely entree mechanism to the information construction

Maxims and stipulations define the application sphere of the type

General Abstract Data Types

They are used to specify a new type from which cases can be created. Here, merely the type of the information elements change harmonizing to what type the list should run on. This extra information could be specified by a generic or general parametric quantity which is specified during case creative activity. Thus an case of a generic ADT is really an case of a peculiar discrepancy of the harmonizing ADT

Notation

As abstract informations types provide an abstract position to depict belongingss of sets of entities, their usage is independent from a peculiar linguistic communication. Hence we introduce a notation here as follows

Datas: This portion describes the construction of the informations used in the abstract informations type in an informal manner.

Operationss: This portion describes valid operations for the information type. It describes its interface and a particular operation builder is used to depict the actions which are to be performed one time an entity is created and destructor to depict the actions which are to be performed one time an entity is destroyed. For each operation the provided statements every bit good as pre-conditions and post-conditions.

Abstract Data Types and OOP

Abstract informations types allow the creative activity of cases with chiseled belongingss and behavior. In OOP, these are referred to as categories. Hence a category defines belongingss of objects which are the cases an environment.

They become functional by citing the involved informations, their construction and their operations as maxims and pre-conditions. Consequently OOP is programming with these informations types uniting functionality of different informations types to work out jobs. Therefore instances objects of these informations types ‘ categories are dynamically created and destroyed

Features of Object Oriented Programming

We already discussed in the old subdivisions about some Object Oriented Programming constructs. Let us now walk through these constructs in item.

Execution of Abstract Data Types

It continues with the treatment about Abstract informations type as an abstract position to specify belongingss of a set of entities. Object Oriented Programming linguistic communications must let execution of these types. Subsequently, once it is implemented, we have a specific representation for it.

Programing linguistic communications such as Pascal, C and others already offer an execution for it. Once we create a variable of this type, we can utilize its provided operations.

OOP is characterised by its major characteristics as follow:

Classs

Objects

Inheritance

Data Abstraction

Data Encapsulation

Polymorphism

Overloading

Reusability

Let us foremost see a sum-up of each of these before continuing to account and illustrations.

FEATURES OF OBJECT ORIENTED PROGRAMMING IN BRIEF

Inheritance:

It is the procedure of organizing a new category from an bing category orA base category ( which is besides known as parent or ace category ) . The hence freshly formed category is called theA derived category ( besides known as kid classA orA sub category ) .A Inheritance helps in cut downing the overall codification size of the plan, which is an of import construct in object-oriented scheduling.

Data Abstraction:

Data Abstraction helps in making user defined informations types and hence increasing the deepness in range for user. It represents the needful information in the plan without demoing the unneeded inside informations.

Data Encapsulation:

Encapsulation combines or encapsulates informations and maps into a individual unit which we ‘ll subsequently mention to as Class. When utilizing Data Encapsulation, information is non accessed straight and is merely accessible through the maps present inside the category. It enables the possibility of informations concealing which comes in ready to hand while programming.

Polymorphism:

Polymorphism allows modus operandis to utilize variables of different types at assorted times. An operator or map can be given different significances or belongingss. Polymorphism refers to a individual map or multi-functioning operator executing in different ways. It can be briefed as enabling multiple faces.

Overloading:

Overloading falls under the class of polymorphism excessively. It allows an object to hold different significances, depending on its context. When an bing operator or map Begins to run on new informations type, it is being overloaded.

Reusability:

This term refers to the ability for multiple coders to utilize the same written and bing category of informations. It saves clip and adds plan codification efficiency to the linguistic communication. Besides, the coder can add in new characteristics to the bing category, therefore further developing the application and leting users to accomplish increased public presentation. This characteristic optimizes codification, helps in deriving secured applications and facilitates easier care on the application.

Objects:

Object is the basic unit of OOP. Objects are identified by an sole name. They represent a peculiar case of a category and there can be more than one case of an object. Each case of an object can keep its ain relevant information. An Object is a aggregation of informations members and associated member maps ( methods ) .

Classs:

Classs are informations types based on which objects are created. Objects with similar belongingss and methods are grouped together in them. A Class represent a set of single objects and the features of these objects are represented asA Properties. Actions that can be performed by objects become maps of the category. No memory is allocated when a category is created and is done merely when an case ( object ) of a category is created.

Class

A category is the execution of an abstract information type. It defines properties and methods which implement the information construction and operations of the these informations types severally. Cases of categories are called objects. Consequently classes define belongingss and behavior of the objects.

Let us see a little illustration for a category.

category xyz

{

int I, K ; //attributes

input ( int g ) ; //method

end product ( ) ; //method

} ;

In the illustration above, the notation category xyz denotes the definition for a category. Enclosed in the curly brackets are two subdivisions viz. properties and methods which define the execution of the information construction and operations of the corresponding abstract informations type. Again we distinguish the two degrees with different footings. In our illustration, the information construction consists of merely one component, a sequence of figures. The corresponding property are ordinary whole numbers of C++ and defied two methods input ( ) and end product ( ) stand foring the two operations get and put.

Object

In the parts of the auto illustration, we saw cases of abstract parts. These cases are existent illustrations of an abstract portion and hence contain existent values to stand for a peculiar portion which are called as objects.

An object is an case of a category. Objects are entirely identified by a name for so. We hence can hold two different objects with the same set of values excessively. This is similar to traditional use where we may hold two whole numbers Js and k both of which can hold same values. We refer to the set of values at a peculiar clip as the province of the object. The province of the object changes harmonizing to the methods which are applied to it. We refer to these possible sequences of province alterations as the object behavior. The behavior of an object is defined by the set of methods which can be applied on it.

Abstraction

The construct ofA abstractionA portions the thought of concealing informations that are non needed for the end-user. The thought behind dataA abstractionA is to give a clear separation between belongingss ofA informations typeA and the associated execution inside informations. This separation is achieved in order that the belongingss of the abstract informations type are seeable to the user interface and the execution inside informations are hidden. Hence, abstractionA forms the basic platform for the creative activity of user-defined informations types called objects. Data abstractionA is the procedure of polishing informations to its indispensable signifier. An Abstract Data Type is defined as a information type that is defined in footings of the operations that it supports and non in footings of its construction or implementation.A

In C++ , as it is an OOP linguistic communication, it is possible to make and supply an interface that accesses merely certain elements of informations types. The coder can make up one’s mind which user to give or allow entree to and conceal the other inside informations. This construct is called informations concealment which is similar in construct to dataA abstraction.

Types of Abstraction

There are two basic types as follows

FunctionalA abstraction

Data abstraction.

The chief difference betweenA functionalA abstractionA and dataA abstractionA is that formerA refers to a map that can be used without taking into history how the map is implemented. Data abstractionA refers to the informations that can be used without taking into history how the informations are stored. There is besides a difference in the manner the entree takes topographic point in functionalA abstractionA and informations abstraction. In functionalA abstraction, entree to the map is provided through a specific interface defined to raise the map. In contrast, in dataA abstraction, entree to the information is provided through a specific set of operations defined to analyze and pull strings the information. For case, when a coder is utilizing C++ criterion informations types, this means that users are utilizing the construct of informations abstraction. When utilizing informations types, the users are non concerned with how the information is stored but they are concerned with what operations are provided and what belongingss are supported.

Need of Abstraction

Flexibility in attack

Enhanced Security

Easier Replacement

ModularA Approach

There are assorted ways of achievingA abstractionA in object-oriented scheduling linguistic communication C++ . One attack is to takeA modularA based codification that is broken apart into smaller sections, known as maps. This functional orA modularA attack helps the codification to be reused once more and once more when needed. For illustration, a coder might compose a map for calculating an norm and another coder might compose a map for calculating salary. These maps can be reused when needed.

Encapsulation

It is the procedure of uniting informations and maps into a individual unit which we named as category. Using encapsulation, we can non straight entree the information. Data is merely accessible through the maps which are inside the category. Data encapsulation led to the of import construct of informations concealing. Data concealment is the execution inside informations of a category that are hidden from the end-user. The construct of restricted entree directed coders to compose specialised maps or methods for executing the operations on concealed members of the category.

Hiding the execution inside informations and supplying restrictive entree leads to the construct of abstract informations type. Encapsulation leads to the construct of informations concealment, but the construct of encapsulation must non be restricted to information concealment. Encapsulation clearly represents the ability to roll up related informations and functionality within a individual, independent entity called a category. Let us see the undermentioned illustration.

category xyz

{

populace:

int input ( int R ) ;

int attention deficit disorder ( ) ;

int end product ( ) ;

private:

int a ;

float B ;

} ;

In the above illustration, the informations members including integer ten and float B, and member maps input ( ) , add ( ) and end product ( ) are bundled and put inside a individual independent entity called category xyz. This demonstrates the construct of Encapsulation. There are advantages of utilizing this encapsulated attack in C++ . One advantage is that it reduces human mistakes. The information and maps bundled inside the category take entire control of care and therefore human mistakes are reduced. It is clear from the above illustration that the encapsulated objects act as a black box for other parts of the plan through interaction. Although encapsulated objects provide functionality, the naming objects will non cognize the execution inside informations. This enhances the security of the application.

The cardinal strength behind Data Encapsulation in C++ is that the keywords or the entree specifiers can be placed in the category declaration as public, protected or private. A category placed after the keyword populace is accessible to all the users of the category. The elements placed after the keyword private are accessible merely to the methods of the category. In between the populace and the private entree specifiers, there exists the protected entree specifier. Elementss placed after the keyword protected are accessible merely to the methods of the category or categories derived from that category.

The construct of encapsulation shows that a non-member map can non entree an object ‘s private or protected informations. This adds security, but in some instances the coder might necessitate an unrelated map to run on an object of two different categories. We so are able to use the construct of friend maps. Encapsulation entirely is a powerful characteristic that leads to information concealment, abstract informations type and friend maps.

Features of Encapsulation:

Makes Maintenance of Application Easier

Improves the apprehension of the Application

Enhanced Security

There are legion grounds for the sweetening of security utilizing the construct of Encapsulation in C++ . The entree specifier acts as the cardinal strength behind the construct of security and provides entree to members of category as needed by users. This prevents unauthorised entree. If an application needs to be extended or customized in ulterior phases of development, the undertaking of adding new maps becomes easier without interrupting bing codification or applications.

Inheritance

Inheritance is the procedure by which new categories called derived categories are created from bing categories called base categories. The derived categories have all the characteristics of the base category and the coder can take to add new characteristics specific to the freshly created derived category.

For illustration, a coder can make a basal category named autos and specify derived categories as tyres, organic structure kits, engine, etc. Each of these derived categories, ( tyres, organic structure kits, and engine ) has all the characteristics of the base category ( autos ) with extra properties or characteristics specific to these freshly created derived categories. This construct of Inheritance leads to the construct of polymorphism.

Features or Advantages of Inheritance

Reusability

Saves Time and Effort

Additions Program Structure which consequences in greater dependability.

Polymorphism

For illustration, if the base category is autos and the derived category is industry, it is specified as:

category industry: public autos

Inheritance Example:

category autos

{

populace:

autos ( ) ;

nothingness rudiment ( int K ) ;

nothingness end product ( nothingness ) { cout & lt ; & lt ; x ; }

private:

int ten ;

} ;

category industry: public autos

{

populace:

sample ( ) ;

nothingness f1 ( int N ) ;

private:

int s1 ;

} ;

Polymorphism

It is the ability to utilize an operator or map in different ways. Polymorphism gives different significances or maps to the operators or maps. Poly, mentioning to many, signifies the many utilizations of these operators and maps. A individual map use or an operator working in many ways can be called polymorphism. Polymorphism refers to codifications, operations or objects that behave otherwise in different contexts.

A simple illustration of the above construct of polymorphism:

1 + 2: Integer Addition

The same + operator can be used with different significances.

“ rudiment ” + “ xyz ” : String concatenation

7.15 + 3.78: Float add-on

Polymorphism is a Strong characteristic of the OOP. A individual operator + behaves otherwise in different contexts such as whole number, float or strings mentioning the construct of polymorphism. The above construct leads to operator overloading. The construct of overloading is besides a subdivision of polymorphism. When the exiting operator or map operates on new informations type it is overloaded. This characteristic of polymorphism leads to the construct of practical methods.

Polymorphism refers to the ability to name different maps by utilizing merely one type of map call. Suppose a coder wants to code vehicles of different forms such as circles, squares, rectangles, etc. One manner to specify each of these categories is to hold a member map for each that makes vehicles of each form. Another convenient attack the coder can take is to specify a basal category named Shape and so make an case of that category. The coder can hold array that hold arrows to all different objects of the vehicle followed by a simple cringle construction to do the vehicle, as per the form desired, by infixing arrows into the defined array. This attack leads to different maps executed by the same map call. Polymorphism is used to give different significances to the same construct. This is the footing for Virtual map execution. C++ provides three different types of polymorphism

Types of Polymorphism

Virtual maps

Function name overloading

Operator overloading

Features of Polymorphism

Helps in reusability of codification.

Provides easier care of applications.

Helps in accomplishing hardiness in applications.

Types of Polymorphism:

ABSTRACT CLASS

With heritage we are able to coerce a subclass to offer the same belongingss like their super-classes. Consequently, objects of a subclass behave like objects of their super-classes.

Sometimes it makes sense to merely depict the belongingss of a set of objects without cognizing the existent behavior beforehand. Let us see the undermentioned illustration

abstract category xyz

{

int a ; //attributes

input ( ) ; //methods

}

We introduce the keyword: abstract. It is used to show the fact that derived categories must redefine the belongingss to fulfill the coveted functionality. Hence from the abstract category point of position, the belongingss are merely specified but non to the full defined. The full definition including the semantics of the belongingss must be provided by derived categories.

A category xyz is called abstract category if it is merely used as a superclass.

Class xyz merely specifies belongingss and it is non used to make objects.

Derived categories must specify the belongingss of xyz.

Abstract categories allow us to construction our heritage graph.

Drumhead

A method is same asA map, but the typical OO notation is used for the call. F ( x, Y ) is written x.F ( Y ) where ten is an object of category that contains this f method.

Sending a message is naming a map ( method ) .

Instantiating is allotment a class/struct object ( case ) withA the “ new ” keyword.

A category is merely a struct with both informations and maps, with OOP characteristics.

Object is an case or a memory allocated to a class/struct. An object is like a C transcript of the category in a useable signifier.

Members are Fieldss or maps of a category if defined inside that category.

Constructor is a function-like codification that initializes new objects ( cases ) when they instantiated.

Destructor is another function-like codification that is called when an object isA deletedA to liberate any resources ( memory ) that has arrows to.

Inheritance is specifying a category ( kid ) in footings of another category ( parent ) . All of the public members of the public category are available in the kid category.

Polymorphism is specifying maps with the same name, but different parametric quantities.

Encapsulation is uniting informations into faculties.

A map is overloaded if there is more than one definition.

Redefine a map from a parent category in a child category is called overruling.

A subclass is the same as kid, derived, or familial category.

A superclass is the same as parent or base category.

An property is same as informations member or member field.

Unstructured scheduling form contains all the codifications in the same map and proves to be inefficient when it comes to lucidity and easiness of debugging.

Procedural scheduling is somewhat more efficient as it contains processs ( maps ) as a portion of the plan which makes it easier to debug.

Modular scheduling is a somewhat higher degree scheduling as the plan is split into many faculties.

Object oriented scheduling is the highest efficiency programming as it handles informations in signifier of categories and objects which make better and efficient usage of resources and lucidity of plan is good along with easy debugging.

Using Abstract informations types we create a defined entity which can be handled. The information construction can merely be accessed with defined undertakings.

Abstraction is of types functional and informations abstraction.

Code reusability is the construct where an bing set of plan codifications are reused alternatively of reiterating them once more.

Abstract category is that derived categories must redefine the belongingss to fulfill the coveted functionality.

Test Yourself Quiz

What is abstraction?

How is polymorphism implemented?

What are the advantages of OOP?

What is overloading?

What is a method?

What are the different scheduling paradigms?

What is modular scheduling?

What are builders and destructors?

What is overruling?

What is code reusability?

Share this Post!

Kylie Garcia

Hi, would you like to get professional writing help?

Click here to start