Sei sulla pagina 1di 24

Introduction to Object Orientation

1
Objectives: Introduction to Object Orientation
Š Understand the basic principles of object orientation
Š Define the basic concepts and terms of object orientation
Š Discuss the strengths of object orientation

2
Introduction to Object Orientation Topics
Š Basic Principles of Object Orientation
Š Basic Concepts of Object Orientation

3
Basic Principles of Object Orientation

Object Orientation

Encapsulation
Abstraction

Modularity

Hierarchy
4
What is Abstraction?

Salesperson

Customer

Product

5
What is Encapsulation?
Š Hide implementation from clients
ƒ Clients depend on interface

6
What is Modularity?
Š The breaking up of something complex into manageable
pieces
Order
Entry

Order Processing
System Order
Fulfillment

Billing

7
What is Hierarchy?
Š Levels of abstraction
Increasing Asset
abstraction

BankAccount Security RealEstate

Savings Checking Stock Bond

Decreasing Classes at the same level of the hierarchy


abstraction should be at the same level of abstraction
8
Introduction to Object Orientation Topics
Š Basic Principles of Object Orientation
Š Basic Concepts of Object Orientation

9
Basic Concepts of Object Orientation
Š Object
Š Class
Š Attribute
Š Operation
Š Component
Š Generalization
Š Polymorphism

10
What is an Object?
Š Behavior
Š State
English 101
Š Unique identity
Intro to OO 180
Geology 110

World History 200


Geology 110

Algebra 110
Music History 200

11
What is a Class?
Š An object is defined by a class

English 101

Intro to OO 180
Geology 110

CourseOffering World History 200


Geology 110

Algebra 110
Music History 200

12
What is an Attribute?

Object
Class

Attribute Attribute Value


:CourseOffering
number = 101
startTime = 900
CourseOffering endTime = 1100
number
startTime
endTime :CourseOffering
Name = 104
startTime = 1300
endTime = 1500

13
What is an Operation?

CourseOffering
Class
addStudent
deleteStudent
getStartTime
Operation getEndTime

14
What Is A Component?
Š A non-trivial, nearly independent, and replaceable part of a
system that fulfills a clear function in the context of a well-
defined architecture
Design Model Implementation Model

<<subsystem>> Component
Component Name Name
Component Component
Interface Interface

15
What is Generalization?
Š One class inherits from another

GroundVehicle
owner Person
ancestor weight
licenseNumber 0..* 1

register( )
generalization

Car Truck Trailer


decendent size tonnage
getTax( )

16
What is Polymorphism?
Š The ability to hide many different implementations behind a
single interface

Manufactor A
Manufactor A Manufactor C

17
Strengths of Object Orientation
Š A single paradigm
ƒ Single language used by users, analysts, designers,
implementers
Š Facilitates architectural and code reuse
Š Models more closely reflect the real world
ƒ More accurately describe corporate data and processes
ƒ Decomposed based on natural partitioning
ƒ Easier to understand and maintain
Š Stability
ƒ A small change in requirements does not mean massive
changes in the system under development

18
A Simple Sales Order Example

Order

Product

Ship via

19
Class Diagram for the Sales Example

Sale

Salesperson Customer Product Vehicle

Corporate Individual Truck Train

20
Effect of Requirements Change
Suppose the requirements
for shipping by a truck
change ... Sale

Salesperson Customer Product Vehicle

Corporate Individual Truck Train

Only the Truck class changes


21
Introduction to Object Orientation Topics
Š Basic Principles of Object Orientation
Š Basic Concepts of Object Orientation

22
Review: Introduction to Object Orientation
Š What are the four basic principles of object orientation?
Provide a brief description of each.
Š What is an Object and what is a Class? What is the
difference between them?
Š What is an Attribute?
Š What is an Operation?
Š What is generalization?
Š What is polymorphism?
Š Describe the strengths of object orientation.

23
REFERENCES
OOAD Using the UML - Introduction to Object Orientation, v 4.0
Copyright  1994-1998 Rational Software, all rights reserved

24

Potrebbero piacerti anche