Question: Part VI. Design Patterns and Refactoring Creational: Factory, Singleton, Builder, Prototype, Interning, Flyweight Structural: Adapter, Composite, Decorator, Flyweight, Proxy Behavioral: Interpreter, Observer, Iterator, Strategy, Model-View-Controller,
Part VI. Design Patterns and Refactoring
Creational: Factory, Singleton, Builder, Prototype, Interning, Flyweight
Structural: Adapter, Composite, Decorator, Flyweight, Proxy
Behavioral: Interpreter, Observer, Iterator, Strategy, Model-View-Controller, Visitor
1. (40pts, 2pts each) Very short (2-3 word) answers.
a) What pattern forces a class to have a single instance?
b) What patterns allow for creation of objects that are subtypes of a given type?
c) What pattern helps reuse existing objects?
d) Can interning be applied to mutable types?
e) Can a mutable class be a Singleton?
f) What design pattern represents complex whole-part objects?
g) What design pattern changes the interface of a class without changing its functionality?
h) What design pattern adds small pieces of functionality without changing the interface?
i) Decorator uses which design pattern?
j) What pattern helps restrict access to an object?
k) What is the difference between an object adapter and a class adapter?
l) Which one is more efficient, an object adapter or a class adapter?
m) What pattern hides a large and complex library and promotes low coupling between the library and the client?
n) What patterns help traverse composite objects?
o) What pattern groups unrelated traversal operations into classes in the composite hierarchy?
p) What patterns group all related traversal operations into separate classes?
q) If you anticipate the composite hierarchy to change while the set of traversal operations stays the same, what pattern would you rather use, Interpreter or Visitor?
r) Conversely, if you anticipate no changes in the composite hierarchy (e.g., BooleanExp doesn?t change), but you expect addition of traversal operations, what pattern would you use, Interpreter or Visitor?
s) What pattern allows for an object to maintain multiple views that must be updated when the object changes?
t) Give an example of usage of the Composite pattern in the Java GUI library
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
