More Inheritance EEE321'10 - PowerPoint PPT Presentation

1 / 20
About This Presentation
Title:

More Inheritance EEE321'10

Description:

A subclass IS A KIND OF superclass. A subclass IS LIKE A superclass ... From: http://bdn.borland.com/article/0,1410,31863,00.html#classdiagrams ... – PowerPoint PPT presentation

Number of Views:21
Avg rating:3.0/5.0
Slides: 21
Provided by: Kni69
Category:

less

Transcript and Presenter's Notes

Title: More Inheritance EEE321'10


1
More Inheritance EEE321.10
Royal Military College of Canada Electrical and
Computer Engineering
  • Maj JW Paul
  • Jeff.Paul_at_rmc.ca
  • 1-613-541-6000 x6656

2
A true Geek2 test
few
few
few
few
VI

few
few
few
few
3
Review
  • Name the two broad categories of polymorphism
  • ad-hoc
  • universal
  • What are their key differences?
  • Name the sub-categories
  • ad-hoc
  • overloading coercion
  • universal
  • sub-type inclusion parametric
  • Give examples

4
Todays Class
  • Some modelling

5
UML Relations Symbols
Dependencies
uses
Generalizations
kind of
bi-directional structural relation
Associations
Aggregation
part of relationships
Composition
see Booch p 73
ATM example
6
Inheritance Tips
  • Look for similarities
  • Look for existing classes
  • Follow the sentence rule
  • A subclass IS A superclass
  • A subclass IS A KIND OF superclass
  • A subclass IS LIKE A superclass
  • Avoid implementation inheritance
  • Inherit everything

7
Aggregation Tips
  • Apply the sentence rule
  • the part is PART OF the whole
  • the whole HAS A part
  • It should be part of the real world
  • You should be interested in the part
  • Show multiplicity and roles
  • Aggregation is inherited

8
Navigation
  • Determines awareness of the relation

Not to be confused with the name and direction of
the relation
9
Example
10
Association Relationships
  • Associations usually represent objects of one
    class making use of objects of another class

What cardinality should we add?
11
Multiplicity (cardinality)
1 only one 1.. one or more 0..1 zero or
one 0.. zero or more (also )
12
Aggregation vs Association
  • It is not always obvious when to use association
    and when to use aggregation
  • There are differing views in the OO world
  • Aggregation often starts out as association, but
    as the semantics of the problem are refined an
    association can become aggregation
  • More important at the implementation perspective

13
When to use Aggregation
  • The lifetime of the part is bound within the
    lifetime of the aggregate - there is a create
    delete dependency of the part on the whole.
  • There is an obvious whole-part physical or
    logical assembly
  • Some properties of the composite propagate to the
    parts, such as its location
  • Operations applied to the composite propagate to
    the parts, such as destruction, movement,
    recording, etc.

14
Aggregation Examples
15
Composition
  • A kind of aggregation
  • Stronger relationship than plain aggregation
  • The part object may belong to only one whole
  • The parts live and die with the whole
  • In implementation the component is structurally
    part of (a field of) the whole

16
Composition
17
Inheritance vs Composition
18
Associations in Java
  • What will they look like?

Components Aggregation Association
19
Review
What are the core concepts of OO? decomposition ab
straction encapsulation hierarchy
From http//bdn.borland.com/article/0,1410,31863,
00.htmlclassdiagrams
20
Review
  • What are the fundamental relationships?
  • Dependencies
  • Generalizations
  • Associations (aggregation composition)
  • What are their key differences?
Write a Comment
User Comments (0)
About PowerShow.com