UML Patterns
UML patterns are used to determine responsibility assignment for objects to interact in a collaboration diagram. Patterns are:
- Identified as a solution.
- A solution to a specific problem type. The solution has a name.
- Solution ideas from experts.
There are several different sets of patterns. The patterns used for collaboration diagram responsibility assognment are General Responsibility Assignment Software Patterns (GRASP). There are:
- Low coupling
- High cohesion
- Expert
- Creator
- Controller
- Pure fabrication
- Indirection
- Don't talk to strangers
- Polymorphism
Use Patterns:
- Evaluative - Patterns that indicate the degree of flexability of the design.
- Low coupling - Coupling measures how much one class relies on another class or is connected to another class. If there are many lines between objects, coupling is high.
- High cohesion - Keep the class as uncomplicated as possible. Don't perform functions not necessary for the respective class.
- Driving Patterns - Patterns used for problem solving.
- Design Patterns
- Singleton (GoF) - Ensure a class has one instance and provide a global path to it. How to implement using java.
- State (GoF) - The state pattern passes a reference to the state it wants to set.
Class Depot
{
public static getInstance() //Get instance of the single depot
{
return instance;
}
private static Depot instance = new Depot();
private Depot()
{
}
}
Java creates the depot the first time getInstance() is called.
- Prototype - Used to make a copy of an object so the copy can be modified without changing the original.
- Flyweight - Don't make the object copy until you change it. References the template directly then apply prototype when a change is made. This pattern uses less memory by not actually making the copy until required.
- Facade (GoF) - An object represents the system as a controller.
- Command - A class for each message. The message is a command. The class has an execute method.
- Forwarder-Receiver (Siemens) - For message handling.
- Layers (Siemens) - Place login in the domain layer, not presentation layer.
- Model-View Separation (Domain-Presentation Separation) - Domain objects do not directly send messages to presentation objects. View objects send messages to domain objects to get information to display.
- Publish-Subscribe (Observer) - A means of allowing the presentation layer to get events to display from the domain layer without polling. An object in the presentation layer would subscribe to be notified of events in the domain layer.
- Proxy/Remote Proxy (GoF) - Make a class that represents the actual class invloved and let the local class communicate with the actual class.
|
|