Dfd2

Post on 29-Jun-2015

184 views 1 download

Tags:

Transcript of Dfd2

Data Flow Diagram

(Design)

Overview:-Overview:-

Data flow diagrams(DFD) are commonly used during problem analysis.

DFD is an useful tool for software engg as well as for the developmnet of other systems.

In fact, dfds have in use long before the discipline of software engg started.

Salient features of any DFD:-Salient features of any DFD:-

DFDs are basically used to show the flow of data through a system.

The System may be an organization,a manual procedure, a software system, a mechanical system,a hardware system or any possible combination of these.

There are several processes in a dfd. Each process is shown by named circles(or bubbles).

Salient features of any DFD(contd….)Salient features of any DFD(contd….)

Data flows are represented by named arrows entering (or leaving) the bubbles.

A rectangle represents the source which is either a net originator or consumer of data.

All external files are shown as a labeled straight line.

When multiple data flows are required by a system this is represented by a ‘*’ between the data flows.This symbol represents the AND operation.

How is a DFD different from a How is a DFD different from a flowchart?flowchart? One must always remember that a dfd is not a

flowchart. While a DFD represents the “flow of data” a flow

chart shows the “flow of control”. A dfd does not represent procedural

information.For eg:- considerations of loops and decisions must be ignored.

In drawing the dfd the designer has to specify what are the major transforms in the flow of the data from the input to the output.

How is a DFD different from a How is a DFD different from a flowchart?(contd…)flowchart?(contd…) How the transforms are occurring is not

the concern of the designer. Error messages are not shown in the dfd.

DFDs for large systems(Leveled DFDs for large systems(Leveled DFDs)DFDs) Many systems are too large for a single dfd to

represent the entire data processing clearly. So, it becomes necessary that some

decomposition and abstraction mechanisms be used for such large systems.

DFDs can be hierarchically organized which helps in progressive partitioning and analyzing of large systems.

Such dfds are called “Leveled DFD set”

How to draw a Leveled DFD set?How to draw a Leveled DFD set? A leveled DFD set has a starting dfd, which is a

very abstract representation of the system identifying the major inputs ,outputs and the major processes in the system.

Then each process is refined and a dfd is shown for the corresponding refinements.

In other words, a bubble in a dfd is expanded into another dfd during refinement.

For the hierarchy to be consistent ,it is necessary that the net inputs and outputs

How to draw a Leveled DFD set?(contd…)How to draw a Leveled DFD set?(contd…)

of a dfd for a process are the same as the inputs and the outputs of the process in the higher level dfd.

This refinement stops if each bubble is considered to be “atomic” ; in that case each bubble can be easily specified or understood.

The top level dfd is sometimes called the “context-diagram”.

Suggestions for DFD construction:-Suggestions for DFD construction:-

Start with a data flow graph with a few major transforms describing the entire transformation form the inputs to the outputs and then refining each transform with more detailed transforms.

We must never try to show the control logic.If we find ourselves to be thinking in terms of loops and decisions then it is time to stop and start again.

Suggestions(contd….)Suggestions(contd….)

Label each arrow with proper data elements and inputs and outputs of each transform needs to be carefully identified.

Make use of ‘*’ and ‘+’ signs and show sufficient data in the data flow graph.

Try and draw alternate data flow graphs before settling on one.

After drawing the dfd the next step is to establish a man-machine boundary by specifying what will be automated and what will remain manual in the dfd for the new system.

Data Dictionary:-Data Dictionary:- Data dictionary is almost a data structure

that keeps track of information about data flows.

Data dictionary states precisely the structure of each data flow in the dfd.

The structure of a data could be defined with different notations which are almost similar to those used for regular expressions.

Data Dictionary:-(contd…)

Some of the commonly used notations are as below:-

“+” indicates composition. “|” indicates one OR the other. “*” indicates one or more occurences.

DFD of a System that Pays Workers :

Employee Record Company Records

Weekly Timesheet Tax Rates

GetEmployee

FileWeekly

Pay

Overtimepay

DeductedPay

IssuePay

Check

Worker

OvertimeRate

OvertimeHours

RegularHoursEmployee

Id

PayRate

Pay NetPay

TotalPay

Check

Worker

Analysis of the dfd system for payment of worker’s:- In this dfd there is one basic input data

flow and that is the weekly time sheet, which originates form the source worker.

The basic output is the paycheck, the sink for which is also the worker.

In this system first the employee’s record is retrieved using the employee id,which is contained in the timesheet.

Analysis of the dfd system for payment of worker’s:- From the employee record the rate of

payment and overtime rate are obtained.These rates and the regular overtime hours(from the timesheet) are used to compute the pay.

After the total pay is determined,taxes are deducted.

Analysis of the dfd system for payment of worker’s:- To compute the tax deduction,information

from the tax-rate file is used.The amount of tax deducted is recorded in the company and employee records.

Finally the paycheck is issued for the net-pay.The amount paid is also recorded in the company records.

A sample Data dictionary:-

The data dictionary for the problem involving the payment of workers is as below:-

Weekly timesheet=Employee_name+Employee_id+[Regular Hours+Overtime Hours]*

Pay_rate=[Hourly|daily|weekly]+Dollar_Amount Employee_name=First+Middle+Last Employee_id=digit+digit+digit+digit

An Example :A restaurant SystemAn Example :A restaurant System

A restaurant owner felts that some amount of automation will help him in making the business more efficient .

DIFFERENT PARTIES INVOLVED:

CLIENT: The Restaurant Owner

POTENTIAL USER: Waiter, Cash register Operator

DFD of a Restaurant System

Supply

Information

Member

Sale

Information

Restaurant

Supplier

Customer

Supply

OrderOfSupplier

Paym

ent

Orders

Receip

t

Final Bill

Several B

ill

Data Flow Diagram of Spell Check Problem:Data Flow Diagram of Spell Check Problem:

New Dictionary

Misspelled Word

Get File Name

Split theWords

SortWords

Lookup Dictionary

Handle Unknown

Word

UserCommand

FileName

Document

Word

List

SortedW

ord List

Dictionary

Word not In

Dictionary

Dictionary

Good Words

Bad Words

Problem 2:Problem 2:Library System:Library System:

NeedsBooks

ChecksThe

Collection

Arranges

Signed onThe card

DeliverReadsReturnsRecollect

File nameReaderPreferable

Book

Librarian

Books

The Particular

Book

Library Card

Selected Book

Reader Librarycard

Books

Jackson Structure Programming

(JSP)

Jagson’s Structured Programming(JSP):- JSP is a systematic technique for mapping the

structure of any problem into a program structure.

The 3 steps for construction of any JSP are:- To draw the “data structure diagram” for each

data set. Form a “program structure diagram” from the

data structure diagram. List all “operations” ,”functional components” and

“conditions”.

JSP for Account Processing System:-

FILE

CUSTOMERS

ACCOUNTS TRANSACTIONS

WITHDRAWL DEPOSIT

Data Structure Diagram:Transaction File

File Header File Body End of File Masker

Customer

Accounts

Account Header Account Body

Transaction

Deposit With Drawal

Program Structure Diagram

Process Process TransactionTransaction FileFile

Program StartProgram Start(1,3)(1,3)

Program BodyProgram Body(c1)(c1)

Program EndProgram End(2,6)(2,6)

Process CustomerProcess Customer(c1 or c2)(c1 or c2)

Process Customer StartProcess Customer Start(7)(7) Process Customer BodyProcess Customer Body

Process accountProcess account

Process Account StartProcess Account Start(3,8)(3,8)

Process Account BodyProcess Account Body(c1 or c2 or c3)(c1 or c2 or c3)

Process TransactionProcess Transaction

Process DepositProcess Deposit(3,4) (3,4)

Process WithdrawalProcess Withdrawal(3,5)(3,5)

Operations:-

1. Open Transaction File.

2. Close Transaction File.

3. Read a Record form the file.

4. Add Amount deposited to the total amount.

5. Add amount withdrawn to the total amount.

6. Output the two totals.

7. Set Current Cust_no Cust_no

8. Set Current Acct_no Account_no

Conditions:-

C1 EOF C2 Cust_no = Current Cust_no C3 Acct_no = Current Acct_no C4 Deposit C4 WithDrawal

JSP for Spelling Checker’s JSP for Spelling Checker’s Problem:-Problem:- Components:-

a)Document File

b)Dictionary File

c)Mispelled Words File Conditions:-

C1 EOF

Spell Check Problem

This problem took each word used in a document and in a dictionary. If a word appears in the dictionary then the word is correct .Otherwise it is displayed in the user terminal, The user then decides if the word is misspelled ,the word is held in a file of misspelled words and if correctly spelled then it is added to the dictionary

Procedure of Spell check problem:

Begin

loop

get next word

add word to word list in sorted order

end from the loop when all word are processed

endloop

contdcontd……..……..loop

get word from sorted word listIf word is not in dictionary then

display the word and prompt on the user terminal if user response says word ok then

add word to the dictionary else

add word to misspelled word list end if

ContdContd end if

exit when all words are processed

end loop

end

Document Misspelled Word List

Dictionary New Dictionary

Basic diagram of Spell Check Problem

Spell checkProblem

T1Sorting

T2Dictionary

Data Structure Diagram Of Spell Check Problem

MisspelledMisspelled Word Word

FileFile

FileFileHeaderHeader

FileFileBodyBody

EOFEOFMarkerMarker

MisspelledMisspelled

Word Word **

GoodGoodWordWord

Bad Bad WordWord

DocumentDocumentFileFile

FileFileHeaderHeader

FileFileBodyBody

EOFEOFMarkerMarker

WordWord

DictionaryDictionaryFileFile

FileFileHeaderHeader

FileFileBodyBody

EOFEOFMarkerMarker

MeaningfulMeaningfulWordWord

Program Structure Diagram Of Spell Check Problem

ProcessProcessSpell CheckSpell Check

Program startProgram start(1)(1)

Program BodyProgram Body(c1)(c1)

Program EndProgram End(2)(2)

Process Process

Document Document **

Start Document Start Document Process(3,4)Process(3,4)

Document Process Document Process BodyBody

ProcessProcess

Word Word **

Start Process Start Process WordWord

Process WordProcess WordBodyBody

ProcessProcess

Document Document **

Cont…Process DictionaryProcess Dictionary

**

Start Dictionary Start Dictionary Process(5)Process(5)

Dictionary Process Dictionary Process BodyBody

Process MisspelledProcess Misspelled Word *Word *

Start Misspelled WordStart Misspelled WordProcess(6,7)Process(6,7)

Misspelled Word Misspelled Word Process BodyProcess Body

Good Word Good Word (3)(3)

Bad WordBad Word(8)(8)

Process DictionaryProcess Dictionary(9)(9)

Operations:-

1. Open document file and dictionary.2. Split the document into words.3. Sort the words.4. Lookup the sorted words in the dictionary.5. Collect the mis-spelt words or output them.6. Add mis-spelt words to mis-spelt word list.7. Identify good words form mis-spelt words.8. Add good words to the dictionary.9. Output the bad words to the user.10. Close the file.

Bank Problem:- A problem is received to process Bank transaction

keyed in at a terminal .The Program is to be menu driven & the menu gives user three option

1. Input of deposit 2. For input of withdrawal3. Terminate program ( option-9)

Deposit are to be written to the deposit file and withdraw are to be written in withdrawal file. Additionally file trailers are to be appended to deposit and withdrawal file containing the total deposit and withdraw respectively

Data Structure Diagram of Bank Transaction(Screen Data Structure Diagram)

Screen InputScreen Input(1)(1)

Input BodyInput Body(2)(2)

Option-9Option-9Terminate(3)Terminate(3)

Menu Menu **

Option -1Option -1Deposit (4)Deposit (4)

Option -2 Option -2 Withdraw (4)Withdraw (4)

Invalid Invalid OptionOption

Data Structure Diagram Of Deposit File and Withdrawal File

Deposit FileDeposit File(1)(1)

File BodyFile Body(2)(2)

File TrailerFile Trailer(3)(3)

Deposit Deposit **(4)(4)

Withdrawal FileWithdrawal File(1)(1)

File BodyFile Body(2)(2)

File TrailerFile Trailer(3)(3)

Withdrawal Withdrawal **(5)(5)

Program Structure Diagram of Bank Transaction Problem

Process Screen Input

Program Start(1,3,4,5)

Program Body(c3)

Program End(2,13,14)

Process *Menu

Process MenuBody(c1,c2)

Process Menu End

Process Option-1Deposit(7,9,11)

Process Option-2Withdrawal

(8.10.12)Process

Data Structure Diagram of File copy Problem

INFILE 1INFILE 1

INFILE 1 INFILE 1 ** INFILE 2 INFILE 2 **

INFILE 2INFILE 2

Program structure Diagram of File Copy

Copy INFILE1 To Copy INFILE1 To INFILE2INFILE2

Program StartProgram Start(1,3)(1,3)

Program BodyProgram Body(C1)(C1)

Program End Program End (2)(2)

Copy INFILE1 To Copy INFILE1 To INFILE 2INFILE 2

(3,4,5)(3,4,5)