0% found this document useful (0 votes)
6 views20 pages

Chapter 04

This document provides an overview of object-oriented (O-O) concepts including objects, classes, instances, generalization, specialization, message-passing, and polymorphism. It discusses the advantages of O-O approaches, such as improved software quality and effort savings through component reuse. The lecture emphasizes the importance of understanding these fundamental concepts for effective systems analysis and design.

Uploaded by

unstable da
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views20 pages

Chapter 04

This document provides an overview of object-oriented (O-O) concepts including objects, classes, instances, generalization, specialization, message-passing, and polymorphism. It discusses the advantages of O-O approaches, such as improved software quality and effort savings through component reuse. The lecture emphasizes the importance of understanding these fundamental concepts for effective systems analysis and design.

Uploaded by

unstable da
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 20

What Is Object-

Orientation?

Based on Chapter 4 of Bennett, McRobb


and Farmer:
Object Oriented Systems Analysis and
Design Using UML, (2nd Edition), McGraw
Hill, 2002.
03/12/2001 © Bennett, McRobb and Farmer 2002 1
In This Lecture You Will
Learn:
 The fundamental concepts of
object-orientation
 The justifications for an object-
oriented approach

06 January 2002 © Bennett, McRobb and Farmer 2002 2


Basic Concepts
 The main concepts introduced here
are:
– Objects, Classes and Instances
– Object State
– Generalization and Specialization
– Message-passing and Encapsulation
– Polymorphism

06 January 2002 © Bennett, McRobb and Farmer 2002 3


Objects
An object is:
“an abstraction of something in a
problem domain, reflecting the
capabilities of the system to
– keep information about it,
– interact with it,
– or both.”
Coad and Yourdon (1990)

06 January 2002 © Bennett, McRobb and Farmer 2002 4


Objects
“Objects have state, behaviour and
identity.”
Booch (1994)
 State: the condition of an object at any
moment, affecting how it can behave
 Behaviour: what an object can do, how
it can respond to events and stimuli
 Identity: each object is unique

06 January 2002 © Bennett, McRobb and Farmer 2002 5


Examples of Objects
Object Identity Behaviour State
Studying, resting,
A person. ‘Hussain Pervez.’ Speak, walk, read. qualified.

My favourite button Pressed, dirty,


A shirt. Shrink, stain, rip.
white denim shirt. worn.

A sale. Sale no #0015, Earn loyalty points. Invoiced,


16/06/02. cancelled.

A bottle of This bottle of Spill in transit. Unsold, opened,


ketchup. empty.
ketchup.

06 January 2002 © Bennett, McRobb and Farmer 2002 6


Class and Instance
 All objects are instances of some
class
 Class:
“a description of a set of objects with
similar
– attributes,
– operations,
– methods
– relationships and semantics.”
OMG (2001)
06 January 2002 © Bennett, McRobb and Farmer 2002 7
Class and Instance
“The purpose of a class is to
declare a collection of methods,
operations and attributes that fully
describe the structure and
behaviour of objects.”
OMG (2001)
 Structure: what an object knows,
information that it holds
 Behaviour: what an object can do
06 January 2002 © Bennett, McRobb and Farmer 2002 8
Class and Instance
An object is:
“an instance that originates from a
class, it is structured and behaves
according to its class.”
OMG (2001)

06 January 2002 © Bennett, McRobb and Farmer 2002 9


Generalization and
Specialization
 Classification is hierarchic in nature
 For example, a person may be an
employee, a customer, a supplier of
a service
 An employee may be paid monthly,
weekly or hourly
 An hourly paid employee may be a
driver, a cleaner, a sales assistant

06 January 2002 © Bennett, McRobb and Farmer 2002 10


Specialization Hierarchy
Person More general
(superclasses)
Employee Customer Supplier

monthly weekly hourly


paid paid paid

Driver Cleaner Sales More specialized


assistant (subclasses)
06 January 2002 © Bennett, McRobb and Farmer 2002 11
Generalization and
Specialization
 More general bits of description are
abstracted out from specialized classes:
General (superclass) Specialized (subclass)

Person HourlyPaidDriver
Name StartDate
Date of birth StandardRate
Gender OvertimeRate
Title LicenceType
06 January 2002 © Bennett, McRobb and Farmer 2002 12
Inheritance
 The whole description of a superclass
applies to all its subclasses, including:
– Information structure
– Behaviour
 Often known loosely as inheritance
 (Actually, inheritance is the facility in
an O-O language that implements
generalization / specialization)

06 January 2002 © Bennett, McRobb and Farmer 2002 13


Message-passing
 Several objects may collaborate to
fulfil each system action
 “Record CD sale” could involve:
– A CD stock item object
– A sales transaction object
– A sales assistant object
 These objects communicate by
sending each other messages
06 January 2002 © Bennett, McRobb and Farmer 2002 14
Message-passing and
Encapsulation
Message from another object
requests a service.
‘Layers of an onion’
model of an object:
Operation called only via valid
operation signature.
An outer layer of
operation signatures…
Data accessed only by
object’s own operations.
…gives access to middle
layer of operations…
An object’s data
is hidden
…which can access (encapsulated).
inner core of data

06 January 2002 © Bennett, McRobb and Farmer 2002 15


Polymorphism
 Polymorphism allows one message to
be sent to objects of different classes
 Sending object need not know what
kind of object will receive the
message
 Each receiving object knows how to
respond appropriately
 For example, a ‘resize’ operation in a
graphics package
06 January 2002 © Bennett, McRobb and Farmer 2002 16
Polymorphism in Resize
Operations

<<entity>>
Campaign
title
campaignStartDate
campaignFinishDate

getCampaignAdverts()
addNewAdvert() <<entity>>
Campaign

title
campaignStartDate
campaignFinishDate

getCampaignAdverts()
addNewAdvert()

06 January 2002 © Bennett, McRobb and Farmer 2002 17


Advantages of O-O
 Can save effort
– Reuse of generalized components cuts
work, cost and time
 Can improve software quality
– Encapsulation increases modularity
– Sub-systems less coupled to each other
– Better translations between analysis
and design models and working code

06 January 2002 © Bennett, McRobb and Farmer 2002 18


Summary
In this lecture you have learned
about:
 The fundamental concepts of O-O
– Object, class, instance
– Generalization and specialization
– Message-passing and polymorphism
 Some of the advantages and
justifications of O-O
06 January 2002 © Bennett, McRobb and Farmer 2002 19
References
 Coad and Yourdon (1990)
 Booch (1994)
 OMG (2001)
(For full bibliographic details, see Bennett,
McRobb and Farmer)

06 January 2002 © Bennett, McRobb and Farmer 2002 20

You might also like