You are on page 1of 10

1

Week 5-6 –Introduction to OOP


Outline
• Introduction to Object Oriented Technology
• Structured Programming VS Object Oriented Programming

 2003 Prentice Hall, Inc. All rights reserved.


2
Thinking About Objects: Introduction
to Object Technology and the Unified
Modeling Language
• Object oriented programming (OOP)
– Model real-world objects with software counterparts
– Attributes (state) - properties of objects
• Size, shape, color, weight, etc.
– Behaviors (operations) - actions
• A ball rolls, bounces, inflates and deflates
• Objects can perform actions as well
– Inheritance
• New classes of objects absorb characteristics from existing classes
– Objects
• Encapsulate data and functions
• Information hiding
– Communicate across well-defined interfaces

 2003 Prentice Hall, Inc. All rights reserved.


3
Thinking About Objects: Introduction
to Object Technology and the Unified
Modeling Language
• User-defined types (classes, components)
– Data members
• Data components of class
– Member functions
• Function components of class
– Association
– Reuse classes

 2003 Prentice Hall, Inc. All rights reserved.


4
Thinking About Objects: Introduction
to Object Technology and the Unified
Modeling Language
• Object-oriented analysis and design (OOAD)
process
– Analysis of project’s requirements
– Design for satisfying requirements
– Pseudocode
• Informal means of expressing program
• Outline to guide code

 2003 Prentice Hall, Inc. All rights reserved.


5

Structured programming vs. OOP

 2003 Prentice Hall, Inc. All rights reserved.


6
Structured programming vs. OOP
(cont)

 2003 Prentice Hall, Inc. All rights reserved.


7
Structured programming vs. OOP
(cont)
• There are two basically different software modularization strategies,
(1) structured programming and (2) object oriented software
development.
• In the "structured programming" (SP) paradigm (view or strategy) the
modules are distinct subalgorithms (representing distinct tasks) called
"procedures" or "functions" ; therefore, modularization in SP involved
the identification, within the overall project, of distinct subtasks and
isolating them in procedures or functions. (Note the focus on "tasks",
i.e. modules which can be represented by algorithms.)
• In the object oriented (OO) paradigm modularization involves
modeling the real world with abstract objects, (called "classes"), which
encapsulate the object's state (data specifying it) and behavior. (Note
the focus on "modelling" of "objects" (things) in the OO paradigm
rather than delineation of "tasks" (analogous to recipes) characteristic
of SP.)

 2003 Prentice Hall, Inc. All rights reserved.


8
Structured programming vs. OOP
(cont)
• However, both of these approaches have the same goal, the
separation of software into distinctive modules that can be
developed independently and later integrated into complex
software applications; in SP, procedures and functions are
integrated in a program; in OOSD, classes are integrated in
software architectures (collections of related classes).

 2003 Prentice Hall, Inc. All rights reserved.


9
Structured programming vs. OOP
(cont)
• There are two fundamental strategies for modularizing software,
structured programming and object-oriented software development.

• In structured programming, modularized is accomplished by


dividing the main algorithm into subalgorithms called procedures
or functions. These procedures and functions can, themselves, be
modularized by creating procedures or functions within them.

– In structured programming, there is no fundamental relationship


between data and behavior, i.e. there is no programming language
facility that binds associated data and operations together. In fact, before
the advent of object technology, data and operations were distinct
quantities of equal importance. Therefore the association of data and its
behavior must be controlled by the program itself, i.e. data must be passed
to procedures or functions via arguments or parameters.

 2003 Prentice Hall, Inc. All rights reserved.


Structured programming vs. OOP 10


(cont)
In object-oriented software development, a real world system is modeled by
a software architecture which is modularized into classes (abstract templates
of real objects) that are "highly cohesive and loosely related". When we
"model" a system in OO software, we specify the state of an object with its
attributes and the behavior of that object with its operations/methods; we only
need to specify the attributes and operations/methods that are necessary to our
model. For example if we are modeling a system that manipulates geometric
objects, we could omit their colors if they are irrelevant to our task.
– This presentation uses a very simplified example that only uses one
(albeit the most important) OO classifier, the class. There are other
classifiers, e.g. interfaces, packages, etc. that are beyond the scope of this
presentation; they will be discussed, briefly, in the following presentation.
– The OO paradigm is a higher level view of software than the algorithmic
view of structured programming.

– Unlike structured programming, there is a fundamental connection


between data and behavior in OOSD, i.e. the class construct
encapsulates related data and operations. Consequently, there is no need
for arguments or parameters to pass data to operations because the data is
"bound" to the operations that define its behavior by being encapsulated
together within a class.
 2003 Prentice Hall, Inc. All rights reserved.

You might also like