Title: More Inheritance EEE321'10
1More 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
2A true Geek2 test
few
few
few
few
VI
few
few
few
few
3Review
- 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
4Todays Class
5UML Relations Symbols
Dependencies
uses
Generalizations
kind of
bi-directional structural relation
Associations
Aggregation
part of relationships
Composition
see Booch p 73
ATM example
6Inheritance 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
7Aggregation 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
8Navigation
- Determines awareness of the relation
Not to be confused with the name and direction of
the relation
9Example
10Association Relationships
- Associations usually represent objects of one
class making use of objects of another class
What cardinality should we add?
11Multiplicity (cardinality)
1 only one 1.. one or more 0..1 zero or
one 0.. zero or more (also )
12Aggregation 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
13When 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.
14Aggregation Examples
15Composition
- 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
16Composition
17Inheritance vs Composition
18Associations in Java
- What will they look like?
Components Aggregation Association
19Review
What are the core concepts of OO? decomposition ab
straction encapsulation hierarchy
From http//bdn.borland.com/article/0,1410,31863,
00.htmlclassdiagrams
20Review
- What are the fundamental relationships?
- Dependencies
- Generalizations
- Associations (aggregation composition)
- What are their key differences?