Lecture 11: Design Patterns, Modeling Interactions and Behavior Flashcards

1
Q

What are design patterns?

A

Recurring aspects of design. A pattern is a general, reusable solution
Good patterns are as general as possible and have an effective solution

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What makes up a design pattern?

A

Context: The general situation in which the pattern applies
Problem: Short description of the main difficulty tackled
Forces: Issues or concerns to consider when solving the problem
Solution: Recommended way to solve the problem

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is an abstraction-occurrence pattern?

A

Context: Domain models often contain sets of related objects (occurrences)
Problem: Finding the best way to represent such occurrences in a class diagram
Forces: Want to avoid duplicating common information
Solution: Create an Abstraction class that contains data common to all members, then create an Occurrence class representing the occurrences of this abstraction. Connect the classes with a one-to-many association

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a general hierarchy pattern?

A

Context: Objects may form a hierarchy
Problem: Representing a hierarchy with limits
Forces: Objects have many common properties
Solution: Create a Node class containing all the features possessed by all objects in the hierarchy. Create a SuperiorNode and link it via Subordinates to the superclass. Create NonSuperiorNode, cannot be linked with subordinates

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are aggregations?

A

Special associations representing “part-whole” relationships. “Whole” side is an aggregate. Denoted by a diamond
Ex: Vehicle <> —– VehiclePart

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a player-role pattern?

A

Context: An object has a particular set of properties (a role)
Problem: Ability to change role
Force: Improve encapsulation, avoid multiple inheritance
Solution: Create a Player class for the object, create an association to an AbstractRole class (which has varying sub classes)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the singleton pattern?

A

Context: Classes for which only one instance should exist
Problem: Ensure it is impossible to make more
Forces: Public constructor can’t guarantee this
Solution: Private class variable that stores the instance. Public method, getInstance(), instantiates on first invocation. Subsequent calls return theInstance

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the delegation pattern?

A

Context: Two classes, one provides service and the other desires it
Problem: Make use of method in another class
Forces: Inheritance isn’t appropriate
Solution: Create a Delegator class with a method that calls another method in Delegate

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the immutable pattern?

A

Context: Object that contains a state which never changes after creation
Problem: Creating immutable instances of a class
Forces: No loopholes permitting modification of object
Solution: Ensure values for the instance variables are only set/modified in the constructor

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How is a sequence diagram set up?

A

Shows the sequence of messages exchanged by a set of objects performing a specific task
Actor (stick figure) on left
Messages are arrows between sender and receiver
Class instances are boxes with class and object identifiers underlined
Vertical dimension represents time

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How is an activity diagram set up?

A

Similar to state diagram except transitions caused by internal events (e.g. completion of computation)
Help understand object or component work flow
Can represent concurrency

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How is a state diagram set up?

A

Describe the behavior of a system, part of a system, or an individual object
Directed graph, where nodes are states and arcs are transitions
System or object is always in some state
Event causes transitions, labeled
Black circle: Start state
Circle with a ring around it: End state

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is a fork?

A

In an activity diagram, there is one incoming transition and multiple outgoing transitions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is a join?

A

In an activity diagram, there are multiple incoming transitions and one outgoing transition
All incoming transitions must occur before proceeding

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is a rendezvous?

A

In an activity diagram, there are multiple incoming and multiple outgoing transitions
All incoming transitions must occur first

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are swim lanes?

A

Partition activities among classes