Download presentation
Presentation is loading. Please wait.
Published byLionel Cox Modified over 8 years ago
1
ECE 452 / CS 446 / SE464 Design Patterns: Part 2 - Questions A Tutorial By Peter Kim Partially based on the tutorial by Michał Antkiewicz
2
Eclipse and Patterns ● Tutorial based on – Erich Gamma, Kent Beck, “Contributing to Eclipse, Principles, Patterns and Plug-ins”, Addison-Wesley, 2004 – Rod Waldhoff’s blog, Implementing the Singleton Pattern in Java, http://radio.weblogs.com/0122027/stories/2003/10/20/im plementingTheSingletonPatternInJava.html ● Extensive use of design patterns ● Plug-in architecture
3
Problem 1: Abstract Syntax Tree Analysis ● In Java Development Tools (JDT) Java code is parsed and represented internally as an abstract syntax tree ● ASTNode represents any node in an abstract syntax tree ● Problem: how to encapsulate various AST analysis algorithms such that it is easy to add new algorithms. Assume that the presented class hierarchy is stable ● Note that analysis algorithm needs to maintain certain information during tree traversal
4
Problem 2: Connecting Viewer to Model ● JFace plug-in provides viewers for standard SWT widgets such as tree, table and list. The viewer's main responsibility is to populate a widget with objects from the model. To do that, a viewer needs to traverse the model and retrieve strings (labels) and icons that the widget can present ● On the other hand a viewer is completely independent from the model it is displaying and the model knows nothing about being displayed (that means viewer and model interfaces are incompatible) ● Good solution is Model-View-Controller pattern ● Which pattern is the most appropriate to connect the viewer (controller) with any model? (viewer needs information such as children, parent, image, text)
5
Problem 3: Workbench ● In Eclipse, the workbench class represents the top of the Eclipse user interface. Its primary responsibility is the management of workbench windows, dialogs, wizards, and other workbench-related windows. ● What pattern can be used to – ensure no one can create instances of Workbench, – only one instance of Workbench is accessible globally, – ensure, there can be at most one instance. ● Present appropriate fragments of code
6
Problem 4: Subclassing Singletons Workbench is to have subclasses, such as EnterpriseWorkbench (for high-end business use) and LightweightWorkbench (for novice use). Assume that the subclass may be chosen at any point in time prior to accessing the Workbench singleton. Show two ways of subclassing the singleton and explain a disadvantage of each way.
7
Problem 5: Proxy Give 3 types of situations where the Proxy design pattern may be applicable and provide an example for each. Think of at least one situation that’s relevant to your project.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.