11-Design Principles
11-Design Principles
1 2
Architectures/Framework
ITSS SOFTWARE DEVELOPMENT (Financial System, J2EE,…)
11. DESIGN PRINCIPLES OOD Patterns
General + OO Concepts
1 2
3 4
1
12/13/19
5 6
2
12/13/19
9 10
11 12
3
12/13/19
22
13 14
15 16
4
12/13/19
17 18
19 20
19 20
5
12/13/19
21 22
23 24
6
12/13/19
25 26
25 26
27 28
27 28
7
12/13/19
29 30
29 30
31 32
31 32
8
12/13/19
33 34
Dependence
Timer
Subclassing
TimeToStretch
33 34
36 37
TimeToStretch v3 Main v3
public class TimeToStretch extends TimerTask { • TimeToStretch tts = new TimeToStretch();
private Timer timer; Register interest with tts.start();
public TimeToStretch() { the timer • Use a callback to invert a dependency
timer = new Timer(this);
} • This diagram shows the inversion of the dependency
public void start() { Callback entry point between Timer and TimeToStretch (compared to v1)
timer.start();
Main does not depend on Timer
} TimeToStretch depends on Timer
Main
public void run() {
System.out.println("Stop typing!");
suggestExercise(); TimerTask Timer
}
...
} TimeToStretch
36 37
9
12/13/19
38 39
38 39
40
40
10