CS540 Software Desi gn 2 Lecture 6 & 7 Specifications Phase Specifications Phase Specification document must be Specification document must be Informal enough for client Informal enough for client Formal enough for developers Formal enough for developers Free of omissions, contradictions, ambiguities Free of omissions, contradictions, ambiguities Specification techniques include Specification techniques include Informal specifications Informal specifications Structured systems analysis Structured systems analysis Object Oriented analysis Object Oriented analysis Entity-relationship modeling Entity-relationship modeling Finite state machines Finite state machines Petri nets Petri nets Other formal techniques such as Z Other formal techniques such as Z specification specification
37
Embed
CS540 Software Design Lecture 6 & 7 1 Lecture 6 & 7: Structured Analysis Anita S. Malik [email protected] Adapted from Schach (2004) Chapter 11.
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
CS540 Software Design 2Lecture 6 & 7
Specifications PhaseSpecifications Phase Specification document must be Specification document must be
Informal enough for clientInformal enough for client Formal enough for developersFormal enough for developers Free of omissions, contradictions, ambiguitiesFree of omissions, contradictions, ambiguities
Specification techniques includeSpecification techniques include Informal specificationsInformal specifications Structured systems analysisStructured systems analysis Object Oriented analysisObject Oriented analysis Entity-relationship modelingEntity-relationship modeling Finite state machinesFinite state machines Petri netsPetri nets Other formal techniques such as Z specificationOther formal techniques such as Z specification
CS540 Software Design 3Lecture 6 & 7
Informal SpecificationsInformal Specifications
ExampleExample““If sales for current month are below If sales for current month are below target sales, then report is to be target sales, then report is to be printed, unless difference between printed, unless difference between target sales and actual sales is less than target sales and actual sales is less than half of difference between target sales half of difference between target sales and actual sales in previous month, or if and actual sales in previous month, or if difference between target sales and difference between target sales and actual sales for the current month is actual sales for the current month is under 5%”under 5%”
CS540 Software Design 4Lecture 6 & 7
Meaning of SpecificationMeaning of Specification Sales target for January was $100,000, actual Sales target for January was $100,000, actual
sales were only $64,000 (36% below target)sales were only $64,000 (36% below target) Print reportPrint report
Sales target for February was $120,000, actual Sales target for February was $120,000, actual sales were only $100,000 (16.7% below target)sales were only $100,000 (16.7% below target) Percentage difference for February (16.7%) less than Percentage difference for February (16.7%) less than
half of previous month’s percentage difference (36%), half of previous month’s percentage difference (36%), do not print report do not print report
Sales target for March was $100,000, actual Sales target for March was $100,000, actual sales were $98,000 (2% below target)sales were $98,000 (2% below target) Percentage difference < 5%, do not printPercentage difference < 5%, do not print
CS540 Software Design 5Lecture 6 & 7
But Specifications Do Not But Specifications Do Not Say ThisSay This
““[D]ifference between target sales and actual [D]ifference between target sales and actual sales”sales” There is no mention of percentage differenceThere is no mention of percentage difference
Difference in January was $36,000, difference Difference in January was $36,000, difference in February was $20,000in February was $20,000 Not less than half of $36,000, so report is printedNot less than half of $36,000, so report is printed
““[D]ifference … [of] 5%” [D]ifference … [of] 5%” Again, no mention of percentageAgain, no mention of percentage
Ambiguity—should the last clause read Ambiguity—should the last clause read “percentage difference … [of] 5%” or “percentage difference … [of] 5%” or “difference … [of] $5,000” or something else “difference … [of] $5,000” or something else entirely?entirely?
Text Processing case studyText Processing case study
CS540 Software Design 7Lecture 6 & 7
Episode 1Episode 1 1969 — Naur Paper1969 — Naur Paper
Given a text consisting of words separated byGiven a text consisting of words separated by blankblank or or byby nlnl (new line) characters, convert it to line-by-line (new line) characters, convert it to line-by-line form in accordance with following rules:form in accordance with following rules:
(1) (1) line breaks must be made only where given text line breaks must be made only where given text has has blankblank or or nl nl ;;
(2)(2) each line is filled as far as possible, as long aseach line is filled as far as possible, as long as
(3)(3) no line will contain more than no line will contain more than maxposmaxpos characters characters Naur constructed a procedure (25 lines of Algol Naur constructed a procedure (25 lines of Algol
60), and informally proved its correctness)60), and informally proved its correctness)
CS540 Software Design 8Lecture 6 & 7
Episode 2Episode 2
1970 — Reviewer in 1970 — Reviewer in Computing Computing ReviewsReviews First word of first line is preceded by a First word of first line is preceded by a
blankblank unless the first word is exactly unless the first word is exactly maxposmaxpos characters long characters long
CS540 Software Design 9Lecture 6 & 7
Episode 3Episode 3
1971 — London found 3 more faults1971 — London found 3 more faults Including: procedure does not terminate Including: procedure does not terminate
unless a word longer than maxpos characters unless a word longer than maxpos characters is encountered is encountered
CS540 Software Design 10Lecture 6 & 7
Episode 4Episode 4
1975 — Goodenough and Gerhart 1975 — Goodenough and Gerhart found 3 further faultsfound 3 further faults Including—last word will not be output unless Including—last word will not be output unless
it is followed by blank or nl it is followed by blank or nl Goodenough and Gerhart then produced new set Goodenough and Gerhart then produced new set
of specifications, about four times longer than of specifications, about four times longer than Naur’sNaur’s
CS540 Software Design 11Lecture 6 & 7
Case Study (contd)Case Study (contd)
1985 — Meyer detected 12 faults in 1985 — Meyer detected 12 faults in Goodenough and Gerhart’s Goodenough and Gerhart’s specificationsspecifications
Goodenough and Gerhart’s specifications Goodenough and Gerhart’s specifications Were constructed with the greatest of careWere constructed with the greatest of care Were constructed to correct Naur’s specificationsWere constructed to correct Naur’s specifications Went through two versions, carefully refereedWent through two versions, carefully refereed Were written by experts in specificationsWere written by experts in specifications With as much time as they neededWith as much time as they needed For a product about 30 lines longFor a product about 30 lines long
What chance do we have of writing fault-free What chance do we have of writing fault-free specifications for a real product?specifications for a real product?
CS540 Software Design 12Lecture 6 & 7
Episode 5Episode 5
1989 — Schach found fault in 1989 — Schach found fault in Meyer’s specificationsMeyer’s specifications Item (2) of Naur’s original requirement (“each Item (2) of Naur’s original requirement (“each
line is filled as far as possible”) is not satisfiedline is filled as far as possible”) is not satisfied
CS540 Software Design 13Lecture 6 & 7
Informal SpecificationsInformal Specifications
ConclusionConclusion Natural language is Natural language is notnot a good way to specify a good way to specify
productproduct FactFact
Many organizations still use natural language, Many organizations still use natural language, especially for commercial productsespecially for commercial products
ReasonsReasons Uninformed managementUninformed management Undertrained computer professionalsUndertrained computer professionals Management gives in to client pressureManagement gives in to client pressure Management is unwilling to invest in trainingManagement is unwilling to invest in training
CS540 Software Design 14Lecture 6 & 7
Structured Systems AnalysisStructured Systems Analysis
Three popular graphical specification Three popular graphical specification methods of ’70smethods of ’70s DeMarcoDeMarco Gane and SarsenGane and Sarsen YourdonYourdon
All equivalentAll equivalent All equally goodAll equally good Many corporations use them for Many corporations use them for
commercial products commercial products Gane and Sarsen used for object-oriented Gane and Sarsen used for object-oriented
designdesign
CS540 Software Design 15Lecture 6 & 7
Structured Systems Analysis Structured Systems Analysis Case StudyCase Study
Sally’s Software Store buys software from various Sally’s Software Store buys software from various suppliers and sells it to the public. Popular software suppliers and sells it to the public. Popular software packages are kept in stock, but the rest must be packages are kept in stock, but the rest must be ordered as required. Institutions and corporations ordered as required. Institutions and corporations are given credit facilities, as are some members of are given credit facilities, as are some members of the public. Sally’s Software Store is doing well, with the public. Sally’s Software Store is doing well, with a monthly turnover of 300 packages at an average a monthly turnover of 300 packages at an average retail cost of $250 each. Despite her business retail cost of $250 each. Despite her business success, Sally has been advised to computerize. success, Sally has been advised to computerize. Should she?Should she?
Better questionBetter question What sections?What sections?
Still betterStill better How? Batch, or online? In-house or out-service?How? Batch, or online? In-house or out-service?
CS540 Software Design 16Lecture 6 & 7
Case Study (contd)Case Study (contd)
Fundamental issue Fundamental issue What is Sally’s objective in computerizing her What is Sally’s objective in computerizing her
business?business? Because she sells software?Because she sells software?
She needs an in-house system with sound and light She needs an in-house system with sound and light effectseffects
Because she uses her business to launder “hot” Because she uses her business to launder “hot” money?money? She needs a product that keeps five different sets of She needs a product that keeps five different sets of
books, and has no audit trailbooks, and has no audit trail Assume: Computerization “in order to make Assume: Computerization “in order to make
more money” more money” Cost/benefit analysis for each section of business Cost/benefit analysis for each section of business
CS540 Software Design 17Lecture 6 & 7
Case Study (contd)Case Study (contd)
The danger of many standard approaches The danger of many standard approaches First produce the solution, then find out what First produce the solution, then find out what
the problem is!the problem is! Gane and Sarsen’s methodGane and Sarsen’s method
Nine-step method Nine-step method Stepwise refinement is used in many stepsStepwise refinement is used in many steps
CS540 Software Design 18Lecture 6 & 7
Case Study (contd)Case Study (contd) Data flow diagram (DFD) shows logical data Data flow diagram (DFD) shows logical data
flow flow ““what happens, not how it happens”what happens, not how it happens”
CS540 Software Design 19Lecture 6 & 7
Step 1. Draw the DFDStep 1. Draw the DFD
First refinementFirst refinement Infinite number of possible interpretationsInfinite number of possible interpretations
Portion of third Portion of third refinementrefinement
CS540 Software Design 22Lecture 6 & 7
Step 1 (contd)Step 1 (contd) Final DFD Final DFD
Larger, But easily understood by client Larger, But easily understood by client Larger DFDsLarger DFDs
HierarchyHierarchy Box becomes DFD at lower levelBox becomes DFD at lower level
Frequent problemFrequent problem Process P at level L, expanded at level L+1Process P at level L, expanded at level L+1 Correct place for sources and destinations of data for Correct place for sources and destinations of data for
process P is level L+1process P is level L+1 Clients cannot understand DFD—sources and destinations Clients cannot understand DFD—sources and destinations
of data for P are “missing”of data for P are “missing” SolutionSolution
Draw “correct” DFD, modify by moving sources and Draw “correct” DFD, modify by moving sources and destinations of data one or more levels updestinations of data one or more levels up
CS540 Software Design 23Lecture 6 & 7
Step 2. Decide What Parts to Step 2. Decide What Parts to ComputerizeComputerize
Depends on how much client is prepared to Depends on how much client is prepared to spendspend
Large volumes, tight controlsLarge volumes, tight controls BatchBatch
Small volumes, in-house microcomputerSmall volumes, in-house microcomputer OnlineOnline
Cost/benefit analysisCost/benefit analysis
CS540 Software Design 24Lecture 6 & 7
Step 3. Refine Data FlowsStep 3. Refine Data Flows
Data items for each data flowData items for each data flow Refine each flow stepwiseRefine each flow stepwise Refine furtherRefine further Need a data dictionaryNeed a data dictionary
CS540 Software Design 25Lecture 6 & 7
Step 3. Refine Data Flows Step 3. Refine Data Flows (contd)(contd)
Sample data dictionary entriesSample data dictionary entries
CS540 Software Design 26Lecture 6 & 7
Step 4. Refine Logic of Step 4. Refine Logic of ProcessesProcesses
Have processHave process give educational discountgive educational discount Sally must explain discount for educational Sally must explain discount for educational
institutionsinstitutions 10% on up to 4 packages, 15% on 5 or more10% on up to 4 packages, 15% on 5 or more
Translate into decision treeTranslate into decision tree
CS540 Software Design 27Lecture 6 & 7
Step 4 (contd)Step 4 (contd) Advantage of decision treeAdvantage of decision tree
Missing items are quickly apparentMissing items are quickly apparent
Can also use decision tables Can also use decision tables CASE tools for automatic translationCASE tools for automatic translation
CS540 Software Design 28Lecture 6 & 7
Step 5. Refine Data StoresStep 5. Refine Data Stores Define exact contents and representation (format) Define exact contents and representation (format)
COBOL: specify to pic levelCOBOL: specify to pic level Ada: specify digits or deltaAda: specify digits or delta
Specify where immediate access is requiredSpecify where immediate access is required Data immediate access diagram (DIAD)Data immediate access diagram (DIAD)
For each file, specifyFor each file, specify File nameFile name Organization (sequential, indexed, etc.)Organization (sequential, indexed, etc.) Storage mediumStorage medium Blocking factorBlocking factor Records (to field level)Records (to field level)
Numerical data for Step 9 to determine Numerical data for Step 9 to determine hardware requirementshardware requirements Volume of input (daily or hourly)Volume of input (daily or hourly) Size, frequency, deadline of each printed Size, frequency, deadline of each printed
reportreport Size, number of records passing between Size, number of records passing between
CPU and mass storageCPU and mass storage Size of each fileSize of each file
DASD requirementsDASD requirements Mass storage for back-upMass storage for back-up Input needsInput needs Output devices Output devices Is existing hardware adequate?Is existing hardware adequate? If not, recommend buy/leaseIf not, recommend buy/lease
CS540 Software Design 33Lecture 6 & 7
HoweverHowever Response times cannot be determinedResponse times cannot be determined Number of I/O channels can only be guessedNumber of I/O channels can only be guessed CPU size and timing can only be guessedCPU size and timing can only be guessed Nevertheless, no other method provides these Nevertheless, no other method provides these
data for arbitrary productsdata for arbitrary products
The method of Gane and Sarsen/De The method of Gane and Sarsen/De Marco/Yourdon has resulted in major Marco/Yourdon has resulted in major improvements in the software industryimprovements in the software industry
Nine Steps:Nine Steps:1.1. Draw the Data Flow Diagram (DFD)Draw the Data Flow Diagram (DFD)2.2. Decide what section to computerizeDecide what section to computerize3.3. Determine the details of the data flowsDetermine the details of the data flows4.4. Define the logic of the processesDefine the logic of the processes5.5. Define the data storesDefine the data stores6.6. Define the physical resourcesDefine the physical resources7.7. Determine input-output specificationsDetermine input-output specifications8.8. Perform sizingPerform sizing9.9. Determine the hardware requirementsDetermine the hardware requirements
CS540 Software Design 35Lecture 6 & 7
Air Gourmet Case Study: Air Gourmet Case Study: Structured Sys. Anal.Structured Sys. Anal.
Data flow diagram Data flow diagram reflects centrality reflects centrality of SPECIAL MEAL of SPECIAL MEAL DATADATA
See Appendix E See Appendix E for remainder of for remainder of structured structured systems analysissystems analysis
CS540 Software Design 36Lecture 6 & 7
Testing during the Testing during the Specification PhaseSpecification Phase
Walkthrough of the documentWalkthrough of the document Inspect the document against a checklist. A study Inspect the document against a checklist. A study
done on inspections showed each hour invested done on inspections showed each hour invested in inspections at analysis stage saved 30 hrs of in inspections at analysis stage saved 30 hrs of execution-based fault detection and correction.execution-based fault detection and correction.
CS540 Software Design 37Lecture 6 & 7
Metrics for Analysis PhaseMetrics for Analysis Phase
Size, cost, duration, effort and qualitySize, cost, duration, effort and quality Size: number of pages in the specification Size: number of pages in the specification
documentdocument Quality: note the number of faults of each type Quality: note the number of faults of each type
found during inspectionfound during inspection Duration and effort: number of items in the data Duration and effort: number of items in the data
dictionary, number of files, data items, processes dictionary, number of files, data items, processes etc.etc.
CS540 Software Design 38Lecture 6 & 7
Challenges of Analysis PhaseChallenges of Analysis Phase
The documents generated during the analysis The documents generated during the analysis phase should be informal enough for the client to phase should be informal enough for the client to understand and formal enough for the understand and formal enough for the development team to use as the description of development team to use as the description of the product to be builtthe product to be built
To keep within the ‘what’ boundary and not cross To keep within the ‘what’ boundary and not cross to the ‘how’ boundaryto the ‘how’ boundary