Systems Analysis and Design II
Systems Analysis and Design II
Design II
2
Design
“There are two ways of
constructing a software design:
One way is to make it so
simple that there are obviously
no deficiencies, and the other
way is to make it so
complicated that there are no
obvious deficiencies.”
3
What Is Design?
■ Requirements specification was about the WHAT
the system will do
■ Design is about the HOW the system will perform
its functions
■ provides the overall decomposition of the system
■ allows to split the work among a team of developers
■ also lays down the groundwork for achieving non-
functional requirements (performance, maintainability,
reusability, etc.)
■ takes target technology into account (e.g., kind of
middleware, database design, web server, UI design,
etc.)
■ The steps in both analysis and design phases are
highly interrelated and may require much “going
back and forth”
4
EVOLVING THE ANALYSIS
MODELS INTO DESIGN
MODELS
System Design
System Design
1. Design
Goals
Definition
8.
Trade-offs
Conditions
Boundary
Initialization
Termination
Failure
2.
Decomposition
System
Layers/Partitions 7. Software
Cohesion/Coupling
Control
Monolithic
Event-Driven
3. Concurrency Threads
Identification of 4. Hardware/ 6. Global Conc. Processes
Threads Software 5. Data Resource Handling
Mapping Management
Access control
Special purpose Persistent Objects Security
Buy or Build Trade-off Files
Databases
Allocation
Connectivity Data structure
6
How to use the results from the
Requirements Analysis for System
Design
■ Nonfunctional requirements =>
■ Activity 1: Design Goals Definition
■ Functional model =>
■ Activity 2: System decomposition (Selection of subsystems
based on functional requirements, cohesion, and coupling)
■ Object model =>
■ Activity 4: Hardware/software mapping
■ Activity 5: Persistent data management
■ Dynamic model =>
■ Activity 3: Concurrency
■ Activity 6: Global resource handling
■ Activity 7: Software control
■ Subsystem Decomposition
■ Activity 8: Boundary conditions
7
System Decomposition
■ Subsystem (UML: Package)
■ Collection of classes, associations, operations, events
and constraints that are interrelated
■ Seed for subsystems: UML Objects and Classes.
■ (Subsystem) Service:
■ Group of operations provided by the subsystem
■ Seed for services: Subsystem use cases
■ Service is specified by Subsystem interface:
■ Specifies interaction and information flow from/to
subsystem boundaries, but not inside the subsystem.
■ Should be well-defined and small.
■ Often called API: Application programmer’s interface, but
this term should used during implementation, not
during System Design
8
Choosing Subsystems
■ Criteria for subsystem selection: Most of the interaction
should be within subsystems, rather than across
subsystem boundaries (High cohesion).
■ Does one subsystem always call the other for the service?
■ Which of the subsystems call each other for service?
■ Primary Question:
■ What kind of service is provided by the subsystems
(subsystem interface)?
■ Secondary Question:
■ Can the subsystems be hierarchically ordered (layers)?
■ What kind of model is good for describing layers and
partitions?
9
Subsystem Decomposition
Example
Is this the right Authoring
decomposition or Augmented
is this too much Reality
ravioli?
Modeling Workflow
Inspection
Workorder Repair
10
Definition: Subsystem
Interface Object
■A Subsystem Interface Object
provides a service
■This is the set of public methods
provided by the subsystem
■The Subsystem interface describes all
the methods of the subsystem
interface object
■Use a Facade pattern for the
subsystem interface object
11
System as a set of subsystems
communicating via a software bus
Authoring
Modeling
Workflow
Augmente
Inspection d
Reality
Repair Workorder
Façade Pattern
13
Façad
Façade
14
A 3-layered Architecture
Repair Inspection Authoring
Augmented
Reality
Workflow
Modeling
Layer 2
Layer 3
21
Syntax for Package
Diagram
A PACKAGE
Package
A DEPENDENCY RELATIONSHIP
22
Modification Dependency
■ Indicates that a change in one package could
cause a change to be required in another
package.
■ Example:
■A change in one method will cause the
interface for all objects of this class to
change. Therefore, all classes that have
objects that send messages to the instances
of the modified class have to be modified.
23
Dependencies
Acyclic Cyclic graph
graph (UNDESIREBLE)
( DESIREBL
E)
24
Package Diagram of
Appointment System
25
Importing and Accessing
Packages
With <<import>>, the elements of imported
package
are accessible without qualification
With <<access>> only the importing package
can
access the elements of the accessed package
26
Steps for Identifying Packages
and Building Package Diagrams
■ Set the context
■ Cluster classes together based on shared
relationships
■ Model clustered classes as a package
■ Identify dependency relationships among
packages
■ Place dependency relationships between
packages
27
Your Turn
■What is the difference between an
analysis modes and a design
model?
■What is a layer? What are the
layers for your project?
■What UML artifact are you going to
use to depict layers and
subsystems?
■What is the difference between a
layer and a partition?
28
Summary so far
■ When evolving analysis into design models, it
is important to review the analysis models
then add system environment information.
■ Packages and package diagrams help provide
structure and less complex views of the new
system.
29
Design Topics
■Introduction to Design
■>>Design Criteria
■Design Goals
■Architecture Styles
■Physical Architecture
■Reuse and Design Patterns
■From Design to Implementation
30
DESIGN CRITERIA
Coupling
■Indicates the interdependence or
interrelationships of the modules
■Interaction coupling
■Relationships with methods and
objects through message passage
32
Interaction Coupling
33
Content Coupling
■ One module directly refers to the content of the other
■ module 1 modifies a statement of module 2
■ assembly languages typically supported this, but not high-level
languages
■ COBOL, at one time, had a verb called alter which could also
create self-modifying code (it could directly change an
instruction of some module).
■ module 1 refers to local data of module 2 in terms of some
kind of offset into the start of module 2.
■ This is not a case of knowing the offset of an array entry - this
is a direct offset from the start of module 2's data or code
section.
■ module 1 branches to a local label contained in module 2.
■ This is not the same as calling a function inside module 2 - this
is a goto to a label contained somewhere inside module 2.
34
Common Coupling
■ Common coupling exists when two or more modules
have read and write access to the same global data.
■ Common coupling is problematic in several areas of
design/maintenance.
■ Code becomes hard to understand - need to know all
places in all modules where a global variable gets modified
■ Hampered reusability because of hidden dependencies
through global variables
■ Possible security breaches (an unauthorized access to a
global variable with sensitive information)
■ It’s ok if just one module is writing the global data and
all other modules have read-only access to it.
35
Common Coupling
■Consider the following code fragment:
while( global_variable > 0 )
{ switch( global_variable )
{ case 1: function_a(); break;
case 2: function_b(); break;
...
case n: ...
}
global_variable++;
}
36
Common Coupling
■ If function_a(), function_b(), etc can modify the value of global
variable, then it can be extremely difficult to track the
execution of this loop.
39
Data Coupling
■Data coupling exhibits the
properties that all parameters to a
module are either simple data
types, or in the case of a record
being passed as a parameter, all
data members of that record are
used/required by the module. That
is, no extra information is passed
to a module at any time.
40
The Law of Demeter
■An object should only send
messages to one of the following:
■Itself
■An object that is contained in an
attribute of the object or its
supercalss
■An object that is passed as a
parameter to the method
■An object that is created by the
method
■An object that is stored in a global
variable 41
Types of Method Cohesion
42
Coincidental cohesion
■The result of randomly breaking the
project into modules to gain the
benefits of having multiple smaller
files/modules to work on
■Inflexible enforcement of rules such as:
“every function/module shall be between 40
and 80 lines in length” can result in
coincidental coherence
■ Problems:
■ Results in hard to understand modules with
complicated logic
■ Undesirable coupling between operations
45
Temporal Cohesion
■ Temporal cohesion concerns a module organized to contain all
those operations which occur at a similar point in time.
46
Procedural Cohesion
■ A module has procedural cohesion if all the operations it
performs are related to a sequence of steps performed in the
program.
47
Procedural Cohesion
Module A Module B
operationA() operationB()
{ readData(data,filename1); { readData(data,filename1);
processAData(data); processBData(data);
storeData(data,filename2); storeData(data,filename2);
} }
readData(data,filename) readData(data,filename)
{ f := { f :=
openfile(filename); openfile(filename);
readrecords(f, data); readrecords(f, data);
closefile(f); closefile(f);
} }
storeData(data,filename) storeData(data,filename)
{...} {...}
processAData(data) processBData(data)
{...} {...}
48
Communicational
Cohesion
■Communicational cohesion occurs when
a module performs operations related to
a sequence of steps performed in the
program (see procedural cohesion) AND
all the actions performed by the module
are performed on the same data.
■Communicational cohesion is an
improvement on procedural cohesion
because all the operations are
performed on the same data.
49
Functional Cohesion
■ Module with functional cohesion focuses on exactly one
goal or “function”
■ (in the sense of purpose, not a programming language
“function”).
51
Types of Class Cohesion
52
Your Turn
■In the diagram below, what
“name” attribute does Robot-
Employee inherit?
53
Summary
■ Cohesion measures the dependence among classes
■ High cohesion: The classes in the subsystem perform
similar tasks and are related to each other (via
associations) GOOD!
■ Low cohesion: Lots of miscellaneous and auxiliary classes,
no associations BAD!!
■ Coupling measures dependencies between subsystems
■ High coupling: Changes to one subsystem will have high
impact on the other subsystem (change of model, massive
recompilation, etc.) BAD!!
■ Low coupling: A change in one subsystem does not affect
any other subsystem GOOD!!
54
DESIGN STRATEGIES
Custom Development
■Develop the system “from scratch”
■Allows for meeting highly specialized
requirements
■Allows flexibility and creativity in solving
problems
■Easier to change components
■Builds personnel skills
■May tax firm’s resources
■May add significant risk
56
Packaged Software
■ Software already written
■ May be more efficient
■ May be more thoroughly tested and proven
■ May range from components to tools to whole
enterprise systems
■ ActiveX, MsWord, SAP,PeopleSoft, Oracle,Ban
■ Must accept functionality provided
■ May require change in how the firm does
business
■ May require significant “customization” or
“workarounds”
57
System Integration
■The process of combining
packages, legacy systems, and
new software
■Key challenge is integrating data
■Write data in the same format
■Revise existing data formats
■Develop “object wrappers”
58
Outsourcing
■Hire external firm to create system
■May have more skills
■May extend existing resources
■Never outsource what you don’t
understand
■Carefully choose vendor
■Prepare contract and payment style
carefully
59
Outsourcing Guidelines
■Keep lines of communication open with
outsourcer
■Define and stabilize requirements
before signing a contract
■View outsourcing relationship as
partnership
■Select outsource vender carefully
■Assign person to manage relationship
■Don’t outsource what you don’t
understand
■Emphasize flexible requirements, long-
term relationships, and short-term
60
contracts
Selecting a Design
Strategy
■Business need
■In-house experience
■Project skills
■Project management
■Time frame
61
Your Turn
■Suppose that your university is
interested in creating a new course
registration system that can support
Web-based registration?
■What should the university consider
when determining whether to invest in a
custom, packaged, or outsourcing
system solution?
62