Object oriented programming system (OOPs):- OOP is a programming language model
Organized around "objects" rather than "actions".The focus of the oop is data.The object is manipulated to gain the required logic of the program.The object can range from human being to floor or buildings.
The first step in oop is to identify all the object u want to manipulate. Then it is identified that how they relate to each other.This procedure is known as Data modelling .The identified object is generalized
as a class of objects &define the kind of data it contains & any logic sequences that can manipulate it.Each distinct logic sequence
Is known as a Method Or Function.
As instance or class instance is what u run in
The computer.It's methods provide computer instructions & the class object characteristics provide relevant data.The user communicates
With objects & objects communicate with each other with well defined interfaces called Messages.
HISTORY:-
" ALAN KAY" coined the term object oriented programming at grad school in 1966or 1967.
The big idea was to use encapsulated mini
Computers in software which communicated
through message passing rather than direct
data sharing to stop breaking down programs
Into separate data structure & procedures.
According to Alan Kay essential ingredients
Of oop are:-
•Message passing
•Encapsulation
•Dynamic binding
Notable inheritance & subclass , polymorphism
Were not considered essential.
Object oriented design started from the
Moment Computers were invented. programming was first & those approaches
Came into picture now. Programming is a set or collection of instructions.
It's actually impossible to develop software
Used in today's scenarios with sequence of bits.This was the main reason programmers
moved on to next generation of programming languages,developing assembly languages ,
Which were near enough to English language
To easily understand.These assembly level
Languages were used in microprocessors,with
The invention of microprocessors assembly language flourished & ruled over the industry,
But it was not enough.Then continued on structured & procedural programming.
Evolution ofOOPs:-
There are different stages as follows:-
• Monolthic programmed approach
• Procedural programmed approach
• Structural programmed approach
• Object oriented programmed approach
• Monolthic programmed approach:-
Here the program consist of sequence of statements that modify data program control
Is achieved using Goto statements.Here code is duplicated each time because there is no
Support for function.This program can be
Accessed from any portion.So it is useful for
designing small & simple programs.
Ex:-ASSEMBLY & BASIC.
• Procedural programmed approach :-
It is top-down approach.Here program is
divided into functions that perform a special task.Control is in the hand of goto statements which avoids repetation of code which is main drawback of Monolthic.But the drwaback over here is data is not secured because data is global & can be accessed by any function.It
Is used for medium sized applications.
Ex:- FORTRAN , COBOL
• Structural programmed approach:-
In this Programmed approach a program is
divided into functions &modules. Theese makes programs more comphrehensible
&helps to maintain control over each function.
It focuses on development of large software
Applications.
EX:-PASCAL, C
• Object oriented programmed approach:-
Basic principal is to combine both data
functions so both can operate into a single unit.Such a unit is called an Object.This
Approach can also secure data.C++ & Java
follow this approach.
Simula (1967) is generally accepted as being the first language with the primary features of an object-oriented language. It was created for making simulation programs in which what came to be called objects were the most important information representation.
Small talk(1972 to 1980) is another early example, and the one with which much of the theory of OOP was developed. Concerning the degree of object orientation, the following distinctions can be made:
- Languages called "pure" OO languages, because everything in them is treated consistently as an object, from primitives such as characters and punctuation, all the way up to whole classes, prototypes, blocks, modules, etc. They were designed specifically to facilitate, even enforce, OO methods. Examples: Ruby, Scala, Small talk,Eiffel,Emerald, Jade, Self,Ramu.
- Languages designed mainly for OO programming, but with some procedural elements. Examples: Java, Python,c++, vb.net
- Languages that are historically procedural languages but have been extended with some OO features. Examples: PHP,visual basic (derived from BASIC)
- Languages with most of the features of objects (classes, methods, inheritance), but in a distinctly original form. Examples: Oberon(Oberon-1 or Oberon-2).
- Languages with Abstract data type support which may be used to resemble OO programming, but without all features of object-orientation. This include object &prototype languages. Examples: Java script
- Chameleon languages that support multiple paradigms, including OO. TCL stands out among these for TclOO, a hybrid object system that supports both prototype programmed database and class-based OO.
Object-oriented programming – As the name suggests uses objects in programming. Object-oriented programming aims to implement real-world entities like inheritance, hiding, polymorphism, etc in programming. The main aim of OOP is to bind together the data and the functions that operate on them so that no other part of the code can access this data except that function.
Characteristics of an Object Oriented Programming language
Class: The building block of C++ that leads to Object-Oriented programming is a Class. It is a user-defined data type, which holds its own data members and member functions, which can be accessed and used by creating an instance of that class. A class is like a blueprint for an object.
For Example: Consider the Class of Cars. There may be many cars with different names and brand but all of them will share some common properties like all of them will have 4 wheels, Speed Limit, Mileage range etc. So here, Car is the class and wheels, speed limits, mileage are their properties.
A Class is a user-defined data-type which has data members and member functions.
Data members are the data variables and member functions are the functions used to manipulate these variables and together these data members and member functions define the properties and behaviour of the objects in a Class.
In the above example of class Car, the data member will be speed limit, mileage etc and member functions can apply brakes, increase speed etc.
We can say that a Class in C++ is a blue-print representing a group of objects which shares some common properties and behaviours.
Object: An Object is an identifiable entity with some characteristics and behaviour. An Object is an instance of a Class. When a class is defined, no memory is allocated but when it is instantiated (i.e. an object is created) memory is allocated.
Object take up space in memory and have an associated address like a record in pascal or structure or union in C.
When a program is executed the objects interact by sending messages to one another.
Each object contains data and code to manipulate the data. Objects can interact without having to know details of each other’s data or code, it is sufficient to know the type of message accepted and type of response returned by the objects.
Encapsulation: In normal terms, Encapsulation is defined as wrapping up of data and information under a single unit. In Object-Oriented Programming, Encapsulation is defined as binding together the data and the functions that manipulate them.
Consider a real-life example of encapsulation, in a company, there are different sections like the accounts section, finance section, sales section etc. The finance section handles all the financial transactions and keeps records of all the data related to finance. Similarly, the sales section handles all the sales-related activities and keeps records of all the sales. Now there may arise a situation when for some reason an official from the finance section needs all the data about sales in a particular month. In this case, he is not allowed to directly access the data of the sales section. He will first have to contact some other officer in the sales section and then request him to give the particular data. This is what encapsulation is. Here the data of the sales section and the employees that can manipulate them are wrapped under a single name “sales section”.
Abstraction: Data abstraction is one of the most essential and important features of object-oriented programming in C++. Abstraction means displaying only essential information and hiding the details. Data abstraction refers to providing only essential information about the data to the outside world, hiding the background details or implementation.
Consider a real-life example of a man driving a car. The man only knows that pressing the accelerators will increase the speed of the car or applying brakes will stop the car but he does not know about how on pressing accelerator the speed is actually increasing, he does not know about the inner mechanism of the car or the implementation of accelerator, brakes etc in the car. This is what abstraction is.
Abstraction using Classes: We can implement Abstraction in C++ using classes. The class helps us to group data members and member functions using available access specifiers. A Class can decide which data member will be visible to the outside world and which is not.
Abstraction in Header files: One more type of abstraction in C++ can be header files. For example, consider the pow() method present in math.h header file. Whenever we need to calculate the power of a number, we simply call the function pow() present in the math.h header file and pass the numbers as arguments without knowing the underlying algorithm according to which the function is actually calculating the power of numbers.
Polymorphism: The word polymorphism means having many forms. In simple words, we can define polymorphism as the ability of a message to be displayed in more than one form.
A person at the same time can have different characteristic. Like a man at the same time is a father, a husband, an employee. So the same person posses different behaviour in different situations. This is called polymorphism.
An operation may exhibit different behaviours in different instances. The behaviour depends upon the types of data used in the operation
Conclusion
Object-oriented programming revolves around the concepts of objects and classes. In Java, the classes are referred as templates for the objects while the objects are instances of a class so, the objects can inherit all the characteristics, variables, and functions of the class. This write-up presents a detailed overview of object-oriented programming in Java. This article provides the answers of what is OOP, why someone should use OOP. Moreover, it explains the concept of objects, classes, methods, and some other fundamental concepts of OOP in Java.
Comments
Post a Comment