Slides12 DesignMechanisms
Slides12 DesignMechanisms
design
Module 12: Identify Design Mechanisms
Objectives: Identify Design
Mechanisms
• Define the purpose of the Identify Design
Mechanisms activity and explain when in
the lifecycle it is performed
• Explain what design and implementation
mechanisms are and how they map from
Analysis mechanisms
• Describe some key mechanisms that will
be utilized in the case study
Identify Design Mechanisms in Context
[Early
Elaboration [Inception
Iteration] Iteration (Optional)]
Analyze Behavior
Supplementary Software
Specifications Architecture
Document
Identify
Design
Mechanisms
Design Model
Analysis Class
Identify Design Mechanisms:
Steps
• Categorize clients of analysis mechanisms
• Document architectural mechanisms
Identify Design Mechanisms: Steps
Categorize clients of analysis mechanisms
Documenting architectural mechanisms
Review: Patterns and
Frameworks
• Pattern
– Provides a common solution to a common
problem in a context
• Analysis/Design Pattern
– Provides a solution to a narrowly scoped
technical problem
– Provides a fragment of a solution, or a piece of
the puzzle
• Framework
– Defines the general approach to solving the
problem
– Provides a skeletal solution, whose details may
be analysis/design patterns
What Is a Design Pattern?
• A design pattern provides a scheme for
refining the subsystems or components of
a software system, or the relationships
between them. It describes a commonly-
recurring structure of communicating
components that solves a general design
problem within a particular context.
Erich Gamma et al. 1994. Design Patterns—Elements of
Reusable Object-Oriented Software
Template
Parameters
Pattern Name
Examples of Pattern Usage
Pattern Example
Command Issue a request to an object without knowing anything about
(behavioral pattern) the operation requested or the receiver of the request: for
example, the response to a menu item, an undo request, the
processing of a time-out
Abstract factory Create GUI objects (buttons, scrollbars, windows, etc.)
(creational pattern) independent of the underlying OS: the application can be
easily ported to different environments
+menu 1
0..*
MenuItem 1 Command
Menu - label : String
+items +cmd + Process()
+ Clicked()
cmd.Process();
Detailing the Command Pattern
(continued)
Application OpenCommand
AskUser();
DoOpen(); + Process()
+cmd
+menu 1
0..*
MenuItem 1 Command
Menu - label : String
+items + Process()
+ Clicked()
cmd.Process();
Detailing the Command Pattern
(continued)
1. OpenCommand( )
myapp ocmd : Initialization
OpenCommand
2. AddItem("Open...",ocmd)
3. MenuItem("Open...", ocmd)
menu aNewItem :
MenuItem
3. AskUser( )
4. DoOpen( )
Application + Process()
+ OpenCommand()
AskUser(); - AskUser()
DoOpen(); - DoOpen()
+menu 1
MenuItem
Menu 0..* - label : String
Clicked(): MenuItem():
cmd.Process(); cmd = c;
label = s;
+cmd
1
Command
+ Process()
Detailing the Command Pattern
(continued)
app
Application CloseCommand
OpenCommand
gui
Menu MenuItem
com
Command
Representing Design Patterns
in UML
• A design pattern is a parameterized
collaboration: The parameters (stereotype <<role>>)
of the collaboration
Client
Invoker <<role>>
ConcreteCommand Client
Command <<role>>
ConcreteCommand
+ Process()
<<role>>
Invoker
Command
+ Process()
Describing Analysis Mechanisms
New Data
Pattern Name
Persistence Distribution
Note: JDBC is the standard Java API for talking to a SQL database.
Example: Persistency: RDBMS:
JDBC
<<role>> Roles to be filled by the <<role>>
PersistencyClient PersistentClassList
(from SamplePersistency Client)
designer applying the (from SamplePersistentClass)
mechanism
new()
add(c: PersistentClass)
<<role>> 1
DBClass 0..*0..*
<<role>>
create() : PersistentClass PersistentClass
read(searchCriteria : String) : PersistentClassList (from SamplePersistentClass)
update(c : PersistentClass)
delete(c : PersistentClass)
getData()
setData()
1
command()
new()
DriverManager
(from java.sql)
ResultSet Statement
Connection
(from java.sql)
(from java.sql) (from java.sql)
: DBClass : DriverManager
1. create( )
1.1. New()
1.2. getData( )
1.3. createStatement( )
1.4. executeUpdate(String)
What Is a Combined Fragment?
A construct within an interaction that
comprises an operator keyword and one or
more interaction operands, each of which is a
fragment of an interaction.
It is shown as a nested region within a sequence diagram.
Client Object Supplier Object
:Client :Supplier
interaction operand
What is an Interaction
Operand?
Each fragment comprises one or more
interaction operands, each a subfragment of
the interaction.
The number of operands depends on the type of
combined fragment.
• For example, a loop has one operand (the loop body)
and a conditional has one or more operands (the
branches of the conditional).
An operand is a nested fragment of an interaction.
• Each operand covers the lifelines covered by the
combined fragment or a subset of them.
What is an Interaction
Expression?
A specification of the range of number of
iterations of a loop.
Range can be specified with minimum and maximum
values
A guard condition, enclosed in square brackets, can be
included on a lifeline.
Client Object Supplier Object
Interaction
:Client :Supplier
Expression
loop (range)
[guard exp]
1: PerformResponsibility
Example : Persistency: RDBMS:
JDBC: Read
: PersistencyClient : DBClass : Connection : Statement : ResultSet : PersistentClassList : PersistentClass
loop
[for each attribute in class] 1.6. getString( )
1.7. setData( )
1.8. add(PersistentClass)
Example: Persistency: RDBMS:
JDBC: Update
: PersistencyClient : DBClass : PersistentClass : Connection : Statement
1. update(PersistentClass)
1.1. getData( )
1.2. createStatement( )
1.3. executeUpdate(string)
execute SQL
statement
Example: Persistency: RDBMS:
JDBC: Delete
: PersistencyClient : DBClass : Connection : Statement
1. delete(PersistentClass)
1.1. createStatement( )
execute SQL
statement
1.2. executeUpdate(string)
Incorporating JDBC: Steps
1. Provide access to the class libraries needed to
implement JDBC
– Provide java.sql package
2. Create the necessary DBClasses
– Assign one DBClass per persistent class
3. Incorporate DBClasses into the design
– Allocate to package/layer
– Add relationships from persistency clients Deferred
Sample
Persistency
Client Package
java.sql
DriverManager Connection
(from java.sql) (from java.sql)
Statement ResultSet
(from java.sql) (from java.sql)
Review: Identify Design
Mechanisms
• What does an analysis mechanism do?
• What is a pattern? What makes a
framework different from a pattern?
• Why should you categorize analysis
mechanisms? Identify the steps.