Software Design Patterns Assignment - Behavioral Patterns
Software Design Patterns Assignment - Behavioral Patterns
Assignment 4
Fall 2020
Question 1:
We have designed an image editor and user can have the option of opening file from various ways like menu, tool bar,
double click on a file in the explorer. Suggest a suitable pattern that enables users to open file in different commands.
Draw class diagram for this system.
Solution:
Suitable pattern is Command design pattern : similar to having an invoker that invokes a special command through
buttons, where each button has a purpose.
UML:
Question 2:
If we have the control library where we have a dialog and some controls over the dialog. The controls can be interacted
or can be changed by themselves. Suggest a suitable pattern that can control the interaction between different objects.
Draw the class diagram.
Solution:
Suitable pattern is the Mediator design pattern. The mediator implements the cooperative behavior by routing requests
between appropriate colleagues.
UML:
Question 3:
When any data is changed in the XML documents object it must notify the list of the active objects attached to the XML
document object and can update all dependent objects. Suggest a suitable pattern and draw class diagram.
Solution:
Observer pattern is a suitable pattern as the XML documents object will be notifying the active objects that use it.
UML: