ANALYSIS OF ALGORITHMS
Download
Report
Transcript ANALYSIS OF ALGORITHMS
Structured Design
and Modeling
CS 123/CS 231
Design Models Revisited
UML: Modeling Language for OO Systems
For the Procedural (Structured) Paradigm
Data and processes are separately
considered
Data Model: Entity-Relationship Diagram
Process Model: Data-Flow Diagram
Some modeling techniques apply to both
paradigms
ERDs
Entity-Relationship Diagrams
Used to produce a data model for an
enterprise
Models data entities, their attributes, and
relationship among data entities
Database Design
Entities and Attributes
Entity
thing, person, place
examples: Book, Sales Invoice, Student,
Customer, Employee, Department, Airport
Attribute
feature of an entity
examples: Name, Address, Age, QCA, Title,
Author, Amount, City
Relationships
Relationship
an association between (at least) two
entities
examples: student borrows a book
Cardinality
One-to-one, one-to-many, many-to-many
Intersection Data
attribute resulting from relationship
example: date-borrowed
The Notation
Rectangles - Entities
Ellipses - Attributes
Diamonds - Relationships
Links
Labels
* Other models omit the diamonds and use
the lines and other notation to denote
relationships
Sample Notation
Example
Example: The University
Setting
Description
Students enroll in classes. Each class is a
section of a particular course.
Entities
Student, Section, Course
name
address
year
id number
qca
Student
index
Student
M
M
enrolls
room
sched
Section
M
grade
1
Course
cat num
title
has
desc
Example 2: Library
Student borrows book
many to many relationship between students
and books
see first diagram
Further analysis reveals there could be
several copies of a book
student borrows copy, book has copy
see second diagram
Student
M
borrows
M
Book
Student
M
M
borrows
Copy
M
1
Book
has
Exercise: Complete Diagram by filling in attributes
ERDs and the
Software Life Cycle
Used at the design phase of the
software life cycle for database
systems, although it is often used as
early as the analysis phase
In design, it precedes table definition
From ERD to Tables
Create a table for each entity
attributes associated to entity are columns of
the table (a primary key should exist per
table)
For each 1:M relationship
add the primary key of the “1” participant as
an attribute of the “M” participant (foreign
key); intersection data is also added to the
“M” participant
ERD to Tables, continued
For each 1:1 relationship
add primary key of one table plus
intersection data to the other table
For each M:M relationship
create a new table
attributes are the primary keys of the
participants plus intersection data
University Setting Example
Student
id number, name, address, year, qca
Section
index, room, sched, cat num
Course
cat num, title, desc
Enroll
id number, index, grade
DFDs
Data Flow Diagrams
Models Operations (Processes)
Also used in analysis and design
Traditional approach
System is a collection of processes
Processes interact with data entities
Processes accept inputs and produce
outputs
DFD Definition
A graphical representation of data
processes in the organization
Depicts the broad overview of system
inputs, processes and outputs
Dataflow approach emphasizes the logic
underlying the system
A tool for system analysis - aid to
conceptualization
Processes
An operation or function in a system
example: Borrow Book
Involves
data flow (input and results)
Data stores, sources and sinks
Example: student and book-copy info are data
that flow into the process; results stored in
borrow table
Notation
Circle (Bubble) or Square with rounded
corners - Process
Arrows - Data Flows
Rectangles – Stores and Entities
(Sources and Sinks)
Labels
id num, copy num
Student
1
Borrow
Book
Copy
borrow confirmation
Borrow
Conventions - Symbols
External entity that can send data or receive data
Source/Origin or Sink/Destination
- Noun
Movement of data from one point to another
- Noun
Transforming process representing work being
performed within the system
- Verb-Adjective-Noun
Repository of data or data store which could
be manual or computerized
- Noun
Comparison of DeMarco & Yourdon
and Gane & Sarson DFD Symbol Sets
Illegal Data Flows
Corrected
data
flows
Illegal
data
flows
B1
B1
DS1
DS1
B2
DS1
B1
DS2
B1
a process is
needed to
exchange data
flows between
boundaries
B1
a process is
needed to
update (or
use) a data
store
DS1
a process is
needed to
present data
from a data
store
DS1
a process is
needed to
move data
from one data
store to
another
B1
DS1
B1
DS2
DFD Levels
A process may involve sub-processes
provides detail about the process
DFD levels emerge
Process hierarchy also depicted using a
structure chart
id num
1.1
Check
Student
Status
borrower status
Student
copy num
Copy
1.2
Check
Book Copy
Status
copy status
borrower status, copy status
id num, copy num
1.3
Record
Borrow
borrow confirmation
Borrow
Copy
Developing DFDs
- Top Down Approach
1. List business activities and determine
external entities
data flows
processes
data stores
2. Create context diagram
show external entities and data flows in and out of
the system
no detailed processes or data stores
Developing DFDs
3. Draw Diagram 0
show processes, keep them general
show data stores at this level
4. Create the Child Diagram/s for all
processes of Diagram 0, as necessary
5. Check for errors and make sure labels
are meaningful
Context Diagram
Highest level and contains only one process
representing the entire system
Broadest possible conceptualization of the
system - bird’s eye view of data movement
Contains the external entities and data flow
to and from the system
No data stores
Numbered 0
Context Diagram
Top-level view of an information system
that shows the system’s boundaries and
scope.
Start by placing the process symbol at the
center; place external entities at the
perimeter
Context Diagram of Hoosier
Burger’s Food Ordering System
Diagram 0 - Next Level
Context diagram explosion into subprocesses; entities and data flows intact
Contains new lower level data flows and
data stores; shows details inside black box
Handling of exceptions is ignored
Up to 9 processes in single sheet
Numbered by integers, left to right
Data stores numbered sequentially - “D#”
Level 0 DFD of Hoosier Burger’s Food
Ordering System
Diagram 0: Food Ordering System
Child Diagram - Low Level
Parent Process in Diagram 0 is exploded
to one or more Child Diagrams
Vertical balancing - Diagram 0 data flows
intact; called “interface data flow”
New data flows; error line included
No external entities
New data stores; Diagram 0 data stores
are optional
Child Diagram - Low Level
Numbering follows Parent Process - “3.1”
Primitive Process
If Parent Process is not exploded and is
functionally primitive
If Child Diagram Process cannot be further
broken down
Logic is written as Process Specifications
Level 1 Diagram Showing Decomposition of
Process 1.0 from the Level 0 Diagram
Diagram 1:
Receive and Transform Customer Order
Level 1 Diagram Showing the Decomposition
of Process 4.0 from the Level 0 Diagram
Diagram 4:
Produce Management Reports
Level 2 Diagram Showing the Decomposition
of Process 4.3 from the Level 1 Diagram for
Process 4.0
Diagram 4.3:
Prepare Management Reports
About DFDs
Data flows should “balance” between
levels
Number label format X.X.X provides level
information
Context Diagram
Level 0 (or system-level) DFD
Notational Variations
Checking for Errors
Forgetting to include a data flow or
pointing the arrow in the wrong direction
shows all inputs and no outputs or vice
versa
Connecting data stores and entities directly should only connect to a process
Incorrect label for process and data flow
Not too many processes in a diagram
cluttered diagram and hinders
communication
Checking for Errors
Omitting data flow; linear flows with
single input and single output are rare
and may indicate missing data
Creating unbalanced decomposition in
child diagrams; interface data flows
should be same as parent
Exception - error lines only in child
diagram
DFD Summary
DFDs are structured analysis tools for
better understanding of the logical
movement of data and its transformation
presented in visual form
DFDs are used to document systems
independent of its analyst
Summary
Modeling techniques and notation
needed in analysis and design
models data and processes of a system
Other techniques and notation
state diagrams, structure charts, flowcharts,
document flow diagrams, more...
Structured vs OO Paradigm
some techniques specific to the paradigm