Lecture 9
Lecture 9
Lecture 9
Design
1
2
3
The Structure Chart
• Structure chart
– A hierarchical diagram showing the relationships
between the modules of a computer program
– The objective of structured design is to create a top-
down decomposition of the functions to be performed
by a given program in a system – use a structure chart
to show this
– E.g. shows functions and sub functions (such as
Calculate base amount, Calculate overtime amount
etc.)
– Uses rectangles to represent each such module (the
basic component of a structure chart
– Higher-level modules are “control” modules that
control flow of execution (call lower level modules
which are the “worker bee” modules that contain 4
program logic)
5
Structure Chart characteristics
10
Developing a Structure Chart
• Transaction analysis
– The development of a structure chart based on a DFD
that describes the processing for several types of
transactions
– Uses as input the system flow chart and the event table
to develop the top level of the tree in a structure chart
• Transform analysis
– The development of a structure chart based on a DFD
that describes the input-process-output data flow
– Used to develop the subtrees in a structure chart – one
for each event in the program
11
Transaction Analysis
• First step is to identify the major programs
– Can do it by looking at the system flow chart and
identifying the major programs
• For a subsystem or program we want to make a
structure chart for, we can look at the DFD Level
0 to identify the major processes
– See next slide, shows event-partitioned DFD for the
order-entry subsystem for RMO example, showing 5
major processes
– These major processes will become the modules in the
resulting high level structure chart (see slide after that)
• Sub-System DFD is also a good source
12
13
14
Transform Analysis
18
Steps continued
20
Steps continued
21
Record
Order
22
Steps continued
23
Record
Order
24
Final Steps
25
Combining the top-level structure chart with
the chart developed by transaction analysis
• Basically “glue” the diagram we made (high-level)
using transaction analysis on top of the more
detailed diagram (for lower-processing) we just
made using transform analysis
• See next slide
26
27
Evaluating the Quality of a Structure Chart
• Module coupling
– The manner in which modules relate to each other
• Desirable to have loosely coupled modules
– have modules as independent as possible
– Module does not need to know who invoked it
– Best coupling is through simple data coupling
• The module is called and a specific set of data items is passed
• Module function performs its function and returns the output
28
Evaluating Structure Charts (continued)
• Cohesion
– Refers to the degree to which all of the code within a
module contributes to implementing one well-defined
task
• Desirable to have modules with high cohesion
implementing a single function
– Modules that implement a single task tend to have
relatively low coupling because all of their internal
code acts on the same data item(s)
– Modules with poor cohesion tend to have high coupling
because loosely related tasks are typically performed on
different data items across modules
– A flag passed down the structure chart is an indicator
of poor cohesion
29
30
Designing the Application Architecture:
The Object-Oriented Approach
• Object-oriented design models provide the bridge
between the object-oriented analysis models and
the object-oriented programs
• Object-oriented programs
– Basic concept: the program consists of a set of
program objects that cooperate to accomplish a result
– Objects work together by sending messages
– Example: in a graphical user interface (GUI) windows
and menus are objects. If you click on a window object
a message is sent to display itself (e.g. window, a menu
bar etc.)
31
Differences between object oriented and
traditional approaches
• In traditional computer environments there is
some sort of central control
– E.g. a mainframe computer may be connected to
thousands of terminals and controls them centrally
– No terminal does work unless directed to by the
mainframe
• In object-oriented environment
– Analogy to a network of nodes, where each node can
send messages to another independently, but all still
work together, not centrally controlled (no one may be
in charge)
32
Overview
33
Object-Oriented Design – The Bridge
Between Analysis and Programming
• Bridge between user’s requirements and new system’s
programming
• Object-oriented design is the process by which detailed
object-oriented models are built
• Programmers use the design to write code and test new
system
• User-interface, network, controls, security, and
database requires design tasks and models
34
Overview of Object-Oriented Programs
35
Simplified Design Class for
Student Class
36
Object-Oriented Design
Processes and Models
• Diagrams developed during analysis
– Use case diagrams, use case descriptions and activity
diagrams, domain model class diagrams, and system
sequence diagrams
• Diagrams developed during design
– Design class diagrams – set of object-oriented classes
needed for programming, navigation between classes,
attribute names and properties and method names and
properties
– Interaction diagrams, package diagrams
37
Design Models with Their
Respective Input Models
38
Iterative Process of OO Design
• Create preliminary design class diagrams model
• Develop interaction diagrams for each use case or
scenario (realization of use cases)
• Return to design class diagram
– Develop method names based on the design of
interaction diagrams
– Update navigation visibility and attributes
• Partition design class diagram into related
functions using package diagrams (subsystems or
layers)
39
Design Class Symbols
• UML does not distinguish between design class
notation and domain model notation
40
Standard Stereotypes Found
in Design Models
41
Standard Design Classes
• Entity – design identifier for problem domain class
– Persistent class – exists after system is shut down
• Boundary – designed to live on system’s
automation boundary
– User interface and windows classes
• Control – mediates between boundary and entity
classes, between the view layer and domain layer
• Data access – retrieve from and send data to
database
42
Design Class Notation
• Name – class name and stereotype information
• Attributes – visibility (private or public), attribute
name, type-expression, initial-value, property
• Method signature – information needed to invoke
(or call) the method
– Method visibility, method name, type-expression
(return parameter), method parameter list (incoming
arguments)
– Overloaded method – method with same name but
two or more different parameter lists
43
Internal Symbols Used to
Define a Design Class
44
Student Class Examples for the
Domain Diagram and the Design
Class Diagram
45
Some Fundamental Design
Principles
• Encapsulation – each object is a self-contained unit
that includes data and methods that access data
• Object reuse – designers often reuse same classes
for windows components
• Information hiding – data associated with object is
not visible to outside world
• Navigation visibility – object is able to view and
interact with another object
46
Navigation Visibility Between
Customer and Order
47
Coupling and Cohesion
• Coupling – qualitative measure of how closely
classes in a design class diagram are linked
– Number of navigation arrows on design class
diagram
– Low: system is easier to understand and maintain
• Cohesion – qualitative measure of consistency
of functions within a single class
– Separation of responsibility – divide low cohesive
class into several highly cohesive classes
48
Developing the First-Cut
Design Class Diagram
• Extend domain model class diagram:
– Elaborate attributes with type and initial value
information
– Add navigation visibility arrows
• Detailed design proceeds, use case by use case:
– Interaction diagrams implement navigation
– Navigation arrows are updated to be consistent
– Method signatures are added to each class
49
RMO Domain Model Class Diagram
50
First-cut RMO Design Class Diagram
51
Interaction Diagrams – Realizing
Use Case and Defining Methods
“Use Case Realization”
• Realization of use case done through
interaction diagram development
52
Partial Design Class Diagram for the Look Up Item
Availability Use Case
53
Use Case Controller
• System sequence diagram (SSD) shows input
messages from external actors within use
case
• Only indicates that messages go to system
• Use case controller classes are designed as
collection point for incoming messages
• Use case controller acts as intermediary
between outside world and internal system
54
Designing with Sequence
Diagrams
• Sequence diagrams used to explain object
interactions and document design decisions
• Documents inputs to and outputs from system
for single use case or scenario
• Captures interactions between system and
external world as represented by actors
• Inputs are messages from actor to system
• Outputs are return messages showing data
55
First-Cut Sequence Diagram
• Start with elements from SSD
• Replace :System object with use case controller
• Add other objects to be included in use case
– Select input message from the use case
– Add all objects that must collaborate
• Determine other messages to be sent
– Which object is source and destination of each
message?
56
SSD for Cancel an Order
Figure 12-4 57
First Cut
Design
Class
Diagram
for Cancel
an Order
Figure 12-5 58
Potential Objects for Cancel an
Order
Figure 12-6 59
First Cut Sequence Diagram
for Cancel an Order
Figure 12-7 60
Guidelines for Sequence Diagram
Development for Use Case
“Use Case Realization”
• Take each input message and determine
internal messages that result from that input
– For that message, determine its objective
– Needed information, class destination, class source,
and objects created as a result
– Double check for all required classes
• Flesh out components for each message
– Iteration, guard-condition, passed parameters, return
values 61
SSD for Create new phone order
Figure 12-8 62
First cut
DCD for
Create
new phone
order
Figure 12-9 63
Sequence Diagram for First Input
Message
Figure 12-10 64
Sequence Diagram for First and Second Input
Messages
Figure 12-10 65
Complete
Sequence
Diagram
Figure 12-11 66
Package Diagrams – Structuring
the Major Components
• High-level diagram in UML to associate classes
of related groups
• Identifies major components of a system and
dependencies
• Determines final program partitions for each layer
– View, domain, data access
• Can divide system into subsystem and show
nesting within packages
67
Partial Design of a Three-Layer Package
Diagram for RMO
68
RMO Subsystem Packages
69