Object Oriented Approach

handprintΛογισμικό & κατασκευή λογ/κού

18 Νοε 2013 (πριν από 3 χρόνια και 8 μήνες)

54 εμφανίσεις

Object Oriented Approach

Object
-
Oriented Approach is
useful for


Understanding problems in a natural way


communicating with application experts


modeling enterprises


preparing documentation


designing programs and databases


What is Procedure
-
Oriented
Programming?


Emphasis is on doing things (algorithms)


Large programs are divided into smaller programs
(functions)


Most of the functions share global data


Data move openly around the system from f
n

to f
n


Functions transforms data from one form to
another


Employs top
-
down approach in program design

Relationship of data & functions
in Procedural Programming

Global Data

Global Data

Function 1

Local Data


Function 2

Local Data


Function 1

Local Data


What is Object Oriented
Programming?


Emphasis is on data rather than procedure


Programs are divided into Objects
(Abstracted into classes)


Data is encapsulated in the objects


Objects communicate with each other
through functions


Follows bottom
-
up approach in program
design

Organization of Data &
Functions in Object
-
Oriented
Programming

Data

Functions

Object A

Data

Functions

Object B

Data

Functions

Object C

Characteristics of Object
-

Oriented Model


Abstraction


Encapsulation


Polymorphism


Inheritance

Abstraction


Focus is on what an Object is & does before
deciding how it should be implemented


Use of abstraction preserves the freedom to
make decision as long as possible by
avoiding premature commitment to details

Encapsulation


Separates the external aspects of an Object,
which are accessible to other objects, from
the internal implementation details of the
object


Prevents a program from becoming so
interdependent that a small change has
massive ripple effects

Polymorphism


The same operation may behave differently
on different classes


An operation is an action or transformation
that an object performs or is subject to


Example: ‘move’ operation may behave
differently on the Windows and ChessPiece
classes

Inheritance


Is the sharing of attributes & operations
among classes based on a hierarchical
relationship


The properties of a super class need not be
repeated in the subclass


Example: ScrollingWindow and
FixedWindow are subclasses of super class
Window