1
15-214
School of Computer Science
Charlie Garrod Michael Hilton School of Computer Science 15-214 - - PowerPoint PPT Presentation
23 GoF Design Patterns an interactive tour Charlie Garrod Michael Hilton School of Computer Science 15-214 1 Administrivia (NEW) Homework 6 out soon. SE for Startups No recitation tomorrow Happy Thanksgiving 15-214 2
1
15-214
School of Computer Science
2
15-214
3
15-214
– “Bolted on” features are difficult to integrate well
4
15-214
5
15-214
6
15-214
7
15-214
– Italic type name indicates abstract class; typically this is an interface when the pattern is used in Java
8
15-214
9
15-214
10
15-214
11
15-214
12
15-214
13
15-214
14
15-214
15
15-214
16
15-214
17
15-214
18
15-214
19
15-214
public class Elvis { public static final Elvis ELVIS = new Elvis(); private Elvis() { } ... } // Alternative implementation public enum Elvis { ELVIS; sing(Song song) { ... } playGuitar(Riff riff) { ... } eat(Food food) { ... } take(Drug drug) { ... } }
20
15-214
21
15-214
22
15-214
image source: https://sourcemaking.com
23
15-214
image source: https://sourcemaking.com
24
15-214
image source: https://sourcemaking.com
25
15-214
26
15-214
27
15-214
28
15-214
29
15-214
30
15-214
31
15-214
Source: http://gameprogrammingpatterns.com/flyweight.html
32
15-214
Source: http://gameprogrammingpatterns.com/flyweight.html
33
15-214
34
15-214
35
15-214