-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDesignPatterns.txt
99 lines (75 loc) · 4.19 KB
/
DesignPatterns.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
Model-View-Controller:
Model:
-Attribute
-Field
-Method
-Class
-Diagram
-Relationship
-SaveLoadSystem
View:
-CommandLineInterface
-GraphicalUserInterface
-GUIDiagramProject
-ClassAsset
-RelationshipAsset
-MenuPrompts
Controller:
-CommandLineInterface
-MenuController
-DiagramProjectController
-MainMenuController
-MenuBarController
-ClassAsset
Strategy:
Algorithm: launchUmlEditor in UserInterface interface
The launchUmlEditor implementation is selected at runtime, between the GUI and CLI version
based on arguments received in the main method on line 17 in the Application class
Chain of Responsibilities:
In the controllers package, there are a multitude of subpackages, that represent controllers,
and subpackages for each controller function with a request, validator, and handler. An
initial request is created, and then sent to a mediator for validation and handling.
Mediator:
The mediator registers services (request, validator, and handler), and serves as a central
point to allow requests to hit each component in a service. Starting on line 37 in the
Startup class, services are registered to the mediator, and mediator.send calls are
made in the controllers.
Command:
There is an abstract 'Request' class, representing a wrapper object for arguments to be sent
to validators and request handlers through the mediator. This slightly varies, as instead of
holding an abstract method in the command itself, the commands are passed into handlers, with
an abstract method taking the place of the abstract method that is typically stored within
the command.
Memento:
The DiagramMemento class stores the current condition of a Diagram before any changes are applied.
Inside a Diagram object is an instance of a DiagramCaretaker. Inside this caretaker is a list of all the
DiagramMemento's made over the course of a project and the logic required to set the Diagram to a previous
instance of itself. The Diagram itself has a method called createSnapshot() that allows it to make a memento
of itself during each change.
Singleton:
The MediatorSingletonHandler maintains one single instance of the protected
Mediator class. An accessor on line 9 allows for the single instance to be
retrieved by client code, and the init on line 13 allows for the instance
to be created if there isn't one already.
Facade:
The Facade pattern is exemplified in all the controller classes. the
DiagramProjectController within the application's architecture is an example of this.
This controller acts as a unified interface to a set of interfaces in the mediator package,
simplifying the user's interaction with more complex subsystems. For instance:
- SaveAsFile, SaveFile, LoadFile, Exit, AddClass, AddRelationship, and Snapshot operations
in DiagramProjectController create respective Request objects and use the mediator to handle
these requests.
- Each public method in the DiagramProjectController represents a high-level functionality,
hiding the underlying complexity involved in executing these operations, such as interacting
with the model, view components, or other controllers.
- This approach simplifies the interaction for clients (like GUI or CLI components) by providing
a straightforward, high-level method for each operation, thus reducing the complexity of direct
interactions with the lower-level subsystems.
- The usage of the Facade pattern in the controller ensures a cleaner and more understandable
interface, promoting ease of use and maintainability.
Prototype:
The Prototype pattern has been implemented into our fields and methods classes, serving as a crucial
component for snapshotting our program. This implementation allows us to create copies of our original
diagram, preserving distinct snapshots without impacting the original reference of the diagram. This
approach ensures that each copy remains independent to further alterations, providing a robust
mechanism for managing program states for our undo/redo system.