Object Orientation - Concepts
Actually Object Orientation is a technique in which we visualize our programming problems in the form of objects and their interaction as happen in real life. For example, we have different objects around us in our daily life that interact with each other to perform different operations. Some examples of objects are given below:
A
person can be an object with
different properties sometimes called data members and methods or functions
sometimes called member functions to perform different actions in real life. A
person may a student, a teacher, a doctor and a scientist.
A
HOUSE is also said to be an object.
It is referred to as a building of college or school or any other department.
It has also some properties and functions.
A House may have number, name, shape, color, height and width. These are called properties or attributes of the house. A house will provide some facilities. These are functions of the house.
A
CAR can be an object which has both
some data member (properties) and member functions (functionality of car). Car Model, Color and Name will be its attributes and Acceleration and Break will be its functions.
A
TREE can also be an object with its
properties and functions. This will be performed according to its nature.
Tree has height and name which will demonstrate its attributes and Growing is its function.
These
objects interact with each other to perform different operations in our real
life. We can see below to understand their relationships and working.
Figure 1.6
Object-orientation- Objects of the program interact
by sending messages to each other.
Take
another example of school; the objects in a school are student, teacher, books, pen, school bag, classroom, parents, playground and so on …… ,
Suppose
we want to develop a fee collection system for a school for this purpose we
need to find out all related objects and their interactions as happen in real
life. In this way we can say that object-orientation makes it easier for us to
solve our real world problems by thinking solution of the problem in the terms
or real world objects.
Finally
we concluded that in our daily life everything can be taken as an object that
behaves in certain way has certain attributes (properties).
Model
In
object-oriented programming the concept of modeling has vital impact. So it is
necessary to understand the models. A model is an abstraction of something real
or conceptual. We need models to understand as aspect of reality.
For example: Highway Maps, Architectural Models, and Mechanical
Models
Object Oriented
Models
In
the context of programming models are used to understand the programming before
starting to develop it. We need to make object-oriented models showing several
interacting objects to understand a system given to us for implementation.
Example 01 – Object Oriented Model
Example 02 – Object Oriented Model
Object Orientation Advantages
Object
Orientation has a lot of advantages for developing software and understanding
the basic concepts of designing and developing the programs. As Object
Orientated Models map directly to reality as we have seen in examples above
therefore there are some advantages of using Object Orientation in programming
given below:
- We can easily develop an Object Oriented Model for a problem.
- Everyone can easily understand an Object Oriented Model.
- We can easily implement an Object Oriented Model for a problem using and object oriented language like as C++. C++ has its features like classes, inheritance, virtual function, polymorphism and abstraction.
What is an Object?
As
we know that Object Oriented Programming languages perform all tasks by using
objects. So it is primary unit of Object Oriented Programming.
An
Object is,
- Something tangible (Ali, School, House, Car). Tangible means all things that can be seen and touched.
- Something conceptual (that can be apprehended intellectually for example time, date, dreams and so on …..).
An
Object has,
- State (attributes – mean properties of the objects)
- Well-defined behavior (Operations – mean functions performed by the object)
- Unique identity
Let
us explain this situation with some examples
ALI is tangible object, having some attributes and Operations given
below,
We can identify Object ALI using his name.