















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!
















117
Design Patterns February 26, 2004
119
123
public interface Node { } public class Number extends Node { public int n; } public class Plus extends Node{ public Node left; public Node right; }
125
public interface Node { public int sum(); } public class Number extends Node { public int n; public int sum() { return n; } } public class Plus { public Node left; public Node right; public int sum() { return left.sum() + right.sum(); } }
One method for each analysis
129
131
aNodeStructure aAssignmentNode^ aVariableRefNode^ aTypeCheckingVisitor Accept (aTypeChecking Visitor) VisitAssignment(aAssignmentNode) VisitVariableRef (aVariableRefNode) Accept (aTypeCheckingVisitor) someOperation() someOperation()
135
137
141
143
147
149
153
Class Monoglyph { … void Draw (Window w) { component.Draw(w); } … } Class Border extends Monoglyph { .. void Draw (Window w) { super.Draw(w); DrawBorder(w); } … }
155