26
OBJECT-ORIENTEDNESS OBJECT-ORIENTEDNESS KCDCC

OBJECT-ORIENTEDNESS KCDCC. WHAT IS OBJECT-ORIENTEDNESS? KCDCC model system as a collection of interacting objects O-O Modelling O-O Programming similar

Embed Size (px)

Citation preview

Page 1: OBJECT-ORIENTEDNESS KCDCC. WHAT IS OBJECT-ORIENTEDNESS? KCDCC model system as a collection of interacting objects O-O Modelling O-O Programming similar

OBJECT-ORIENTEDNESSOBJECT-ORIENTEDNESS

KCDCC

Page 2: OBJECT-ORIENTEDNESS KCDCC. WHAT IS OBJECT-ORIENTEDNESS? KCDCC model system as a collection of interacting objects O-O Modelling O-O Programming similar

WHAT IS OBJECT-ORIENTEDNESS?WHAT IS OBJECT-ORIENTEDNESS?

KCDCC

model system as a collection ofinteracting objects

O-O Modelling <--> O-O Programming

similar conceptual philosophy

different purpose

Page 3: OBJECT-ORIENTEDNESS KCDCC. WHAT IS OBJECT-ORIENTEDNESS? KCDCC model system as a collection of interacting objects O-O Modelling O-O Programming similar

OBJECTSOBJECTS

KCDCC

what is an object?

individuality

properties

real world thing - something tangible

conceptual / virtual / abstract

all objects have identity

all objects are distinguishable - twins

identity - state - behaviour

(identity - data - operations)

Page 4: OBJECT-ORIENTEDNESS KCDCC. WHAT IS OBJECT-ORIENTEDNESS? KCDCC model system as a collection of interacting objects O-O Modelling O-O Programming similar

There are many THINGS in the World

From: Sigfried S (1996). Understanding Object-Oriented Software Engineering

Page 5: OBJECT-ORIENTEDNESS KCDCC. WHAT IS OBJECT-ORIENTEDNESS? KCDCC model system as a collection of interacting objects O-O Modelling O-O Programming similar

The World Our Model

From: Sigfried S (1996). Understanding Object-Oriented Software Engineering 5/26

Page 6: OBJECT-ORIENTEDNESS KCDCC. WHAT IS OBJECT-ORIENTEDNESS? KCDCC model system as a collection of interacting objects O-O Modelling O-O Programming similar

OBJECTS (cont..)OBJECTS (cont..)

KCDCC

individual, identifiable entity (real or abstract)

with a well defined rolein the problem domain

Page 7: OBJECT-ORIENTEDNESS KCDCC. WHAT IS OBJECT-ORIENTEDNESS? KCDCC model system as a collection of interacting objects O-O Modelling O-O Programming similar

OBJECT PROPERTIESOBJECT PROPERTIES

KCDCC

identity

state (data)

behaviour (operations/methods)

property of an object which distinguishes it from all other objects

attributes of an object

attributes have values

describes how object acts & reacts

procedures / operations (messages)

Page 8: OBJECT-ORIENTEDNESS KCDCC. WHAT IS OBJECT-ORIENTEDNESS? KCDCC model system as a collection of interacting objects O-O Modelling O-O Programming similar

OBJECT PROPERTIES (cont.)OBJECT PROPERTIES (cont.)

KCDCC

attributes (data)

behaviour (operations/methods)

descriptor (variable) that holds valuee.g. name, weight, colour, model,

may have same across classese.g. weight

function or procedure that may be applied to or by an object

e.g. Move, Open, Draw, ...

all objects in a class share same operations

Page 9: OBJECT-ORIENTEDNESS KCDCC. WHAT IS OBJECT-ORIENTEDNESS? KCDCC model system as a collection of interacting objects O-O Modelling O-O Programming similar

CLASSES AND INSTANCESCLASSES AND INSTANCES

KCDCC

instance (object)

class

unique individual

all values unique

individuality from differences in attribute values (but may differ in only location & orientation)

abstraction - generalization

group of objects with common properties

differentiation in attributes

attributes can have ranges / options

Page 10: OBJECT-ORIENTEDNESS KCDCC. WHAT IS OBJECT-ORIENTEDNESS? KCDCC model system as a collection of interacting objects O-O Modelling O-O Programming similar

From: Sigfried S (1996). Understanding Object-Oriented Software Engineering

Similar THINGS can be GROUPED

10/26

Page 11: OBJECT-ORIENTEDNESS KCDCC. WHAT IS OBJECT-ORIENTEDNESS? KCDCC model system as a collection of interacting objects O-O Modelling O-O Programming similar

From: Rumbaugh et al. (1991). Object-Oriented Modeling and Design

Page 12: OBJECT-ORIENTEDNESS KCDCC. WHAT IS OBJECT-ORIENTEDNESS? KCDCC model system as a collection of interacting objects O-O Modelling O-O Programming similar

From: Rumbaugh et al. (1991). Object-Oriented Modeling and Design

Page 13: OBJECT-ORIENTEDNESS KCDCC. WHAT IS OBJECT-ORIENTEDNESS? KCDCC model system as a collection of interacting objects O-O Modelling O-O Programming similar

CLASS RELATIONSHIPSCLASS RELATIONSHIPS

KCDCC

taxonomical / typological

aggregation

others

a_kind_of, a_type_of, is_a, an_instance_of ako, ato, isa, aio

a_part_of, a_component_of apo, aco

functional, ownership, connectivity, ... provides_access, owned_by, joins

Page 14: OBJECT-ORIENTEDNESS KCDCC. WHAT IS OBJECT-ORIENTEDNESS? KCDCC model system as a collection of interacting objects O-O Modelling O-O Programming similar

depends on purpose

CLASSIFICATIONCLASSIFICATION

KCDCC

brings order

no simple recipe

knowledge ordered hierarchically

linked to categorization

no perfect class structure & set of objects

difficult - boundaries are fuzzy e.g. where does knee begin and end

difficult to define precisely attributes & values e.g. cup and bowl

different views

Page 15: OBJECT-ORIENTEDNESS KCDCC. WHAT IS OBJECT-ORIENTEDNESS? KCDCC model system as a collection of interacting objects O-O Modelling O-O Programming similar

CLASSIFICATION (cont.)CLASSIFICATION (cont.)

KCDCC

superclass, subclass, instance

general to specific

fewer members - more specific

ancestors - descendants

parent - child

15/26

Page 16: OBJECT-ORIENTEDNESS KCDCC. WHAT IS OBJECT-ORIENTEDNESS? KCDCC model system as a collection of interacting objects O-O Modelling O-O Programming similar

INHERITANCEINHERITANCE

KCDCC

superclass, subclass, instance

C1

superclass

instance

superclasssubclass

subclass

A

B

C

ato

ato

aio

recursive

reuse

subclass inherits all properties of superclass

instance special case of subclass

inherit ‘up the line’

if class B subclass of class A and class C subclass of class B then class C inherits from class B and class A

avoids redundancy

Page 17: OBJECT-ORIENTEDNESS KCDCC. WHAT IS OBJECT-ORIENTEDNESS? KCDCC model system as a collection of interacting objects O-O Modelling O-O Programming similar

From: Rumbaugh et al. (1991). Object-Oriented Modeling and Design

Page 18: OBJECT-ORIENTEDNESS KCDCC. WHAT IS OBJECT-ORIENTEDNESS? KCDCC model system as a collection of interacting objects O-O Modelling O-O Programming similar

vehicle

landvehicle

watervehicle

amphibiousvehicle

car boat

MULTIPLE INHERITANCEMULTIPLE INHERITANCE

ato ato

atoato ato ato

18/26

Page 19: OBJECT-ORIENTEDNESS KCDCC. WHAT IS OBJECT-ORIENTEDNESS? KCDCC model system as a collection of interacting objects O-O Modelling O-O Programming similar

GENERALIZATION / SPECIALIZATIONGENERALIZATION / SPECIALIZATION

KCDCC

generalization

specialization

extract common characteristics

create higher-level abstraction

bottom-up

top-down

may constrain ancestor attributes e.g. circle special case of ellipse

must do one of above

add new features - extension e.g. hinged door adds swing behaviour

Page 20: OBJECT-ORIENTEDNESS KCDCC. WHAT IS OBJECT-ORIENTEDNESS? KCDCC model system as a collection of interacting objects O-O Modelling O-O Programming similar

AGGREGATION / DECOMPOSITIONAGGREGATION / DECOMPOSITION

assembly / component

KCDCC

recursive

structural hierarchy

special form of relationship

aggregate object made up of component objects

treated as one unit - an object

orthogonal concept to generalization/specialization

components may be aggregations

part/whole vs subclass/class

apo, aco vs ako, ato, isa, aio

20/26

Page 21: OBJECT-ORIENTEDNESS KCDCC. WHAT IS OBJECT-ORIENTEDNESS? KCDCC model system as a collection of interacting objects O-O Modelling O-O Programming similar

KCDCC

lamp

fluorescentlamp

incandescentlamp

ballast starter socket

AGGREGATION / DECOMPOSITIONaddition of components

base cover switch

ato

aco

acoaco

Page 22: OBJECT-ORIENTEDNESS KCDCC. WHAT IS OBJECT-ORIENTEDNESS? KCDCC model system as a collection of interacting objects O-O Modelling O-O Programming similar

KCDCC

lamp

fluorescentlamp

ballast starter

AGGREGATION / DECOMPOSITIONaddition of components (cont.)

base cover switch

ato

aco

aco

L1

base1 cover1 switch1

aco

ballast1 starter1

isa

isaisa

isa

isaisa

22/26

Page 23: OBJECT-ORIENTEDNESS KCDCC. WHAT IS OBJECT-ORIENTEDNESS? KCDCC model system as a collection of interacting objects O-O Modelling O-O Programming similar

O-O CONCEPTSO-O CONCEPTS

encapsulation / modularity

KCDCC

classification

inheritance

aggregation

localize data & procedures in a module

taxonomic / typologic hierarchy

makes order

reusability

structural hierarchy

hides / adds details

Page 24: OBJECT-ORIENTEDNESS KCDCC. WHAT IS OBJECT-ORIENTEDNESS? KCDCC model system as a collection of interacting objects O-O Modelling O-O Programming similar

O-O LANGUAGESO-O LANGUAGES

Smalltalk first popular OOL

C++ strongly typed - lots of housekeeping

Eiffel strongly typed - garbage collection

CLOS (Common Lisp Object System) O-O extension of COMMON LISP

encapsulation not enforced Objective C

Java cleaned-up version of C++ - no pointers distributed

KCDCC

Page 25: OBJECT-ORIENTEDNESS KCDCC. WHAT IS OBJECT-ORIENTEDNESS? KCDCC model system as a collection of interacting objects O-O Modelling O-O Programming similar

O-O DATABASESO-O DATABASES

databases

KCDCC

O-O programming

OODMS

relationships

used to store persistent data

data doesn’t vanish when program stops execution

objects

not persistent

object information persistent

25/26

Page 26: OBJECT-ORIENTEDNESS KCDCC. WHAT IS OBJECT-ORIENTEDNESS? KCDCC model system as a collection of interacting objects O-O Modelling O-O Programming similar

IMPACT OF 0-0 SYSTEMS ON MODELLINGIMPACT OF 0-0 SYSTEMS ON MODELLING

CAD systems & applications

KCDCC

data exchange & integration

no standard model for O-O systems

implemented using O-O technology

systems create and manipulate objects

information embedded in objects

use O-O concepts

concepts of state and behaviour fundamental

26/26