Tuesday, September 14, 2010

Lesson1

Object-Orientation (OO)

What is Object-Orientation?

It is a technique in which we visualize our programming problems in the form of
objects and their interactions as happens in real life.

Examples:
We have different objects around us in our real life that interact with each other to
perform different operations for example,


These objects interact with each other to perform different operations,


Take another example of a School; the objects in a school are student, teacher, books,
pen ,school bag, classroom, parents, playground and so on… ,


Objects in a School


Suppose we want to develop a fee collection system for a school for this we will need
to find out related objects and their interactions as happens 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 terms of real world objects.

So we can say that in our daily life everything can be taken as an object that behaves in a
certain way and has certain attributes.

In object orientation we move our concentration to objects in contrast to procedural
paradigm in which we simply write our code in functions and call them in our main
program.

What is a Model?

A model is an abstraction of something real or conceptual.
We need models to understand an aspect of reality.

Model Examples

Highway maps
Architectural models
Mechanical models

OO Models:

In the context of programming models are used to understand the problem before
starting developing it.
We make Object Oriented models showing several interacting objects to understand
a system given to us for implementation.

Example 1– Object Oriented Model


Example 2– Object Oriented Model (A School Model)



Object-Orientation - Advantages

As Object Oriented Models map directly to reality as we have seen in examples
above therefore,

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 any object
oriented language like c++ using its features1 like classes, inheritance, virtual
functions and so on…
What is an Object?

An object is,

1. Something tangible (Ali, School, House, Car).
2. Something conceptual (that can be apprehended intellectually for example
time, date and so on…).

An object has,

1. State (attributes)
2. Well-defined behavior (operations)
3. Unique identity

Tangible and Intangible Objects

Examples of Tangible Objects:


Ali is a tangible object, having some characteristics (attributes) and behavior as given below,



We will identify Ali using his name.

Car is also a tangible object having some characteristics (attributes) and behavior
given below,



We can identify Car using its registration number

Examples of Intangible Objects (also called as conceptual objects):

Time is an intangible (conceptual) object



We will assign our own generated unique ID in the model for Time object

Date is also an intangible (conceptual) object



We will assign our own generated unique ID in the model for Date object.

Summary
Model is the abstraction of some real word scenario. It helps us to understand
that scenario.

Object oriented model of any scenario (problem) describes that scenario
(problem) in the form of interacting objects.

We use Object Orientation because it helps us in mapping real world problem
in a programming language.

Object Orientation is achieved using objects and their relationships.

Properties of an object are described using its data members and behavior of an
object is described using its functions.

Objects may be tangible (physical) or intangible (also called conceptual or
virtual).

Generally when we have given a certain problem description, nouns in that
problem description are candidates for becoming objects of our system.

There may be more than one aspects of an object

It is not necessary that every object has a specific role in implementation of a
problem there may be some objects without any role, like school parking in
our school.

It is easier to develop programs using Object Oriented Programming because
it is closer to real life.

No comments:

Post a Comment