Скачать презентацию Function-Oriented Software Design continued Lecture 6 Dr R Скачать презентацию Function-Oriented Software Design continued Lecture 6 Dr R

b8651aa26da6f3be63654a2f61c7be25.ppt

  • Количество слайдов: 80

Function-Oriented Software Design (continued): Lecture 6 Dr. R. Mall Function-Oriented Software Design (continued): Lecture 6 Dr. R. Mall

Organization of this Lecture z Brief review of previous lectures z A larger example Organization of this Lecture z Brief review of previous lectures z A larger example of Structured Analysis z Structured Design y. A major objective of this lecture is that you should be able to develop structured design from any DFD model. z Examples z Summary

Review of Last Lecture z. Last lecture we started discussion on Structured Analysis/ Structured Review of Last Lecture z. Last lecture we started discussion on Structured Analysis/ Structured Design (SA/SD) technique: yincorporates features from some important design methodologies. z. SA/SD consists of two important parts: ystructured analysis ystructured design.

Review of Last Lecture z. The goal of structured analysis: yperform functional decomposition. yrepresent Review of Last Lecture z. The goal of structured analysis: yperform functional decomposition. yrepresent using Data Flow Diagrams (DFDs). z. DFDs are a hierarchical model: y. We examined why any hierarchical model is easy to understand ynumber 7 is called the magic number.

Review of Last Lecture z During structured analysis: y. Functional decomposition takes place yin Review of Last Lecture z During structured analysis: y. Functional decomposition takes place yin addition, data decomposition takes place. z At the most abstract level: ycontext diagram yrefined to more detailed levels. z We discussed two small examples: y. RMS calculating software ytic-tac-toe computer game software

Review of Last Lecture z. Several CASE tools are available yhelp in design activities: Review of Last Lecture z. Several CASE tools are available yhelp in design activities: yhelp maintain the data dictionary, ycheck whether DFDs are balanced, etc. z. DFD model: ydifficult to implement using a programming language: yneeds to be transformed to structured design.

Example 3: Trading-House Automation System (TAS) z. A large trading house wants us to Example 3: Trading-House Automation System (TAS) z. A large trading house wants us to develop a software: yto automate book keeping activities associated with its business. z. It has many regular customers: ywho place orders for various kinds of commodities.

Example 3: Trading-House Automation System (TAS) z The trading house maintains names and addresses Example 3: Trading-House Automation System (TAS) z The trading house maintains names and addresses of its regular customers. z Each customer is assigned a unique customer identification number (CIN). z As per current practice when a customer places order: ythe accounts department first checks the credit-worthiness of the customer.

Example: Trading-House Automation System (TAS) z The credit worthiness of a customer is determined: Example: Trading-House Automation System (TAS) z The credit worthiness of a customer is determined: yby analyzing the history of his payments to the bills sent to him in the past. z If a customer is not credit-worthy: yhis orders are not processed any further yan appropriate order rejection message is generated for the customer.

Example: Trading-House Automation System (TAS) z. If a customer is credit-worthy: yitems he/she has Example: Trading-House Automation System (TAS) z. If a customer is credit-worthy: yitems he/she has ordered are checked against the list of items the trading house deals with. z. The items that the trading house does not deal with: yare not processed any further yan appropriate message for the customer for these items is generated.

Example: Trading-House Automation System (TAS) z. The items in a customer's order that the Example: Trading-House Automation System (TAS) z. The items in a customer's order that the trading house deals with: y are checked for availability in the inventory. z. If the items are available in the inventory in desired quantities: ya bill with the forwarding address of the customer is printed. ya material issue slip is printed.

Example: Trading-House Automation System (TAS) z. The customer can produce the material issue slip Example: Trading-House Automation System (TAS) z. The customer can produce the material issue slip at the store house: ytake delivery of the items. yinventory data adjusted to reflect the sale to the customer.

Example: Trading-House Automation System (TAS) z. If an ordered item is not available in Example: Trading-House Automation System (TAS) z. If an ordered item is not available in the inventory in sufficient quantity: yto be able to fulfill pending orders store details in a "pendingorder" file : xout-of-stock items along with quantity ordered. xcustomer identification number

Example: Trading-House Automation System (TAS) z. The purchase department: ywould periodically issue commands to Example: Trading-House Automation System (TAS) z. The purchase department: ywould periodically issue commands to generate indents. z. When generate indents command is issued: ythe system should examine the "pending-order" file ydetermine the orders that are pending ytotal quantity required for each of the items.

Example: Trading-House Automation System (TAS) z. TAS should find out the addresses of the Example: Trading-House Automation System (TAS) z. TAS should find out the addresses of the vendors who supply the required items: yexamine the file containing vendor details (their address, items they supply etc. ) yprint out indents to those vendors.

Example: Trading-House Automation System (TAS) z. TAS should also answers managerial queries: ystatistics of Example: Trading-House Automation System (TAS) z. TAS should also answers managerial queries: ystatistics of different items sold over any given period of time ycorresponding quantity sold and the price realized.

Context Diagram indent query Manager statistics order Customer Trading-House. Automation. System 0 response Generateindent Context Diagram indent query Manager statistics order Customer Trading-House. Automation. System 0 response Generateindent Purchase. Department

Level 1 DFD Customer-history Customer-file order Acceptorder 0. 1 Accepted-orders Vendor-list Indent-request Indents Item-file Level 1 DFD Customer-history Customer-file order Acceptorder 0. 1 Accepted-orders Vendor-list Indent-request Indents Item-file Handleindentrequest 0. 4 query inventory Processorder 0. 2 statistics Handlequery 0. 3 Sales-statistics pending-order Material-issue-slip + bill

Example: Data Dictionary z response: [bill + material-issue-slip, reject-message] z query: period /* query Example: Data Dictionary z response: [bill + material-issue-slip, reject-message] z query: period /* query from manager regarding sales statistics*/ z period: [date+date, month, year, day] z date: year + month + day z year: integer z month: integer z day: integer z order: customer-id + {items + quantity}* z accepted-order: order /* ordered items available in inventory */ z reject-message: order + message /* rejection message */ z pending-orders: customer-id + {items+quantity}* z customer-address: name+house#+street#+city+pin

Example: Data Dictionary z z z item-name: string house#: string street#: string city: string Example: Data Dictionary z z z item-name: string house#: string street#: string city: string pin: integer customer-id: integer bill: {item + quantity + price}* + total-amount + customeraddress material-issue-slip: message + item + quantity + customeraddress message: string statistics: {item + quantity + price }* sales-statistics: {statistics}* quantity: integer

Observation z. From the examples, yobserve that DFDs help create: xdata model xfunction model Observation z. From the examples, yobserve that DFDs help create: xdata model xfunction model

Observation z. As a DFD is refined into greater levels of detail: ythe analyst Observation z. As a DFD is refined into greater levels of detail: ythe analyst performs an implicit functional decomposition. y. At the same time, refinements of data takes place.

Guidelines For Constructing DFDs z. Context diagram should represent the system as a single Guidelines For Constructing DFDs z. Context diagram should represent the system as a single bubble: y. Many beginners commit the mistake of drawing more than one bubble in the context diagram.

Guidelines For Constructing DFDs z. All external entities should be represented in the context Guidelines For Constructing DFDs z. All external entities should be represented in the context diagram: yexternal entities should not appear at any other level of DFD. z. Only 3 to 7 bubbles per diagram should be allowed: yeach bubble should be decomposed to between 3 and 7 bubbles.

Guidelines For Constructing DFDs z. A common mistake committed by many beginners: yattempting to Guidelines For Constructing DFDs z. A common mistake committed by many beginners: yattempting to represent control information in a DFD. ye. g. trying to represent the order in which different functions are executed.

Guidelines For Constructing DFDs z A DFD does not represent control information: ywhen or Guidelines For Constructing DFDs z A DFD does not represent control information: ywhen or in what order different functions (processes) are invoked ythe conditions under which different functions are invoked are not represented. y. For example, a function might invoke one function or another depending on some condition. y. Many beginners try to represent this aspect by drawing an arrow between the corresponding bubbles.

Example-1 z Check the input value: y. If the input value is less than Example-1 z Check the input value: y. If the input value is less than -1000 or greater than +1000 generate an error message yotherwise search for the number Gener number Chec k numb er number ate message Error Searc [found, not-found] h

Guidelines For Constructing DFDs z. If a bubble A invokes either bubble B or Guidelines For Constructing DFDs z. If a bubble A invokes either bubble B or bubble C depending on some conditions: yrepresent the data that flows from bubble A to bubble B and bubbles A to C ynot the conditions depending on which a process is invoked.

Example-2 z A function accepts the book name to be searched from the user Example-2 z A function accepts the book name to be searched from the user z If the entered book name is not a valid book name y generates an error message, z If the book name is valid, y searches the book name in the database. Get-bookname Book-name Good-bookname Print-errmessage Searchbook Book-details Errormessage

Guidelines For Constructing DFDs z. All functions of the system must be captured in Guidelines For Constructing DFDs z. All functions of the system must be captured in the DFD model: yno function specified in the SRS document should be overlooked. z. Only those functions specified in the SRS document should be represented: ydo not assume extra functionality of the system not specified by the SRS document.

Commonly made errors Unbalanced DFDs Forgetting to mention the names of the data flows Commonly made errors Unbalanced DFDs Forgetting to mention the names of the data flows Unrepresented functions or data External entities appearing at higher level DFDs Trying to represent control aspects Context diagram having more than one bubble A bubble decomposed into too many bubbles in the next level z Terminating decomposition too early z Nouns used in naming bubbles z z z z

Shortcomings of the DFD Model z. DFD models suffer from several shortcomings: z. DFDs Shortcomings of the DFD Model z. DFD models suffer from several shortcomings: z. DFDs leave ample scope to be imprecise. y. In a DFD model, we infer about the function performed by a bubble from its label. y. A label may not capture all the functionality of a bubble.

Shortcomings of the DFD Model z. For example, a bubble named findbook-position has only Shortcomings of the DFD Model z. For example, a bubble named findbook-position has only intuitive meaning: ydoes not specify several things: xwhat happens when some input information is missing or is incorrect. x. Does not convey anything regarding what happens when book is not found xor what happens if there are books by different authors with the same book title.

Shortcomings of the DFD Model z Control information is not represented: y. For instance, Shortcomings of the DFD Model z Control information is not represented: y. For instance, order in which inputs are consumed and outputs are produced is not specified. Item-file Customer-history Customer-file order Accepted-orders inventory Processorder

Shortcomings of the DFD Model z. A DFD does not specify synchronization aspects: y. Shortcomings of the DFD Model z. A DFD does not specify synchronization aspects: y. For instance, the DFD in TAS example does not specify: xwhether process-order may wait until the accept-order produces data xwhether accept-order and handle-order may proceed simultaneously with some buffering mechanism between them.

TAS: Level 1 DFD Customer-history Customer-file order Item-file Acceptorder Accepted-orders query inventory statistics Handlequery TAS: Level 1 DFD Customer-history Customer-file order Item-file Acceptorder Accepted-orders query inventory statistics Handlequery Processorder Vendor-list Indent-request Indents Handleindentrequest Sales-statistics pending-order

Shortcomings of the DFD Model z The way decomposition is carried out to arrive Shortcomings of the DFD Model z The way decomposition is carried out to arrive at the successive levels of a DFD is subjective. z The ultimate level to which decomposition is carried out is subjective: ydepends on the choice and judgement of the analyst. z Even for the same problem, yseveral alternative DFD representations are possible: ymany times it is not possible to say which DFD representation is superior or preferable.

Shortcomings of the DFD Model z DFD technique does not provide: yany clear guidance Shortcomings of the DFD Model z DFD technique does not provide: yany clear guidance as to how exactly one should go about decomposing a function: yone has to use subjective judgement to carry out decomposition. z Structured analysis techniques do not specify when to stop a decomposition process: yto what length decomposition needs to be carried out.

Extending DFD Technique to Real. Time Systems z. For real-time systems (systems having time Extending DFD Technique to Real. Time Systems z. For real-time systems (systems having time bounds on their actions), yessential to model control flow and events. y. Widely accepted technique: Ward and Mellor technique. xa type of process (bubbles) that handles only control flows is introduced. x. These processes are represented using dashed circles.

Structured Design z The aim of structured design ytransform the results of structured analysis Structured Design z The aim of structured design ytransform the results of structured analysis (i. e. , a DFD representation) into a structure chart. z A structure chart represents the software architecture: yvarious modules making up the system, y module dependency (i. e. which module calls which other modules), yparameters passed among different modules.

Structure Chart z Structure chart representation yeasily implementable using programming languages. z Main focus Structure Chart z Structure chart representation yeasily implementable using programming languages. z Main focus of a structure chart: ydefine the module structure of a software, yinteraction among different modules, yprocedural aspects (e. g, how a particular functionality is achieved) are not represented.

Basic building blocks of structure chart z. Rectangular box: y. A rectangular box represents Basic building blocks of structure chart z. Rectangular box: y. A rectangular box represents a module. yannotated with the name of the module it represents. Process-order

Arrows z An arrow between two modules implies: yduring execution control is passed from Arrows z An arrow between two modules implies: yduring execution control is passed from one module to the other in the direction of the arrow. root Process-order Handle-indent Handle-query

Data flow Arrows z Data flow arrows represent: ydata passing from one module to Data flow Arrows z Data flow arrows represent: ydata passing from one module to another in the direction of the arrow. root order Process-order

Library modules z. Library modules represent frequently called modules: y a rectangle with double Library modules z. Library modules represent frequently called modules: y a rectangle with double side edges. y. Simplifies drawing when a module is called by several modules. Quick-sort

Selection z The diamond symbol represents: yone module of several modules connected to the Selection z The diamond symbol represents: yone module of several modules connected to the diamond symbol is invoked depending on some condition. root Process-order Handle-indent Handle-query

Repetition z A loop around control flow arrows denotes that the concerned modules are Repetition z A loop around control flow arrows denotes that the concerned modules are invoked repeatedly. root Process-order Handle-indent Handle-query

Structure Chart z There is only one module at the top: ythe root module. Structure Chart z There is only one module at the top: ythe root module. z There is at most one control relationship between any two modules: yif module A invokes module B, ymodule B cannot invoke module A. z The main reason behind this restriction: yconsider modules in a structure chart to be arranged in layers or levels.

Structure Chart z. The principle of abstraction: ydoes not allow lower-level modules to invoke Structure Chart z. The principle of abstraction: ydoes not allow lower-level modules to invoke higherlevel modules: y. But, two higher-level modules can invoke the same lower-level module.

Example root rms Valid-numbers Get-good-data Get-data Compute-solution Validate-data rms Display-solution Example root rms Valid-numbers Get-good-data Get-data Compute-solution Validate-data rms Display-solution

Bad Design Bad Design

Shortcomings of Structure Chart z. By looking at a structure chart: ywe can not Shortcomings of Structure Chart z. By looking at a structure chart: ywe can not say whether a module calls another module just once or many times. z. Also, by looking at a structure chart: ywe can not tell the order in which the different modules are invoked.

Flow Chart (Aside) z We are all familiar with the flow chart representations: z Flow Chart (Aside) z We are all familiar with the flow chart representations: z z z y Flow chart is a convenient technique to represent the flow of control in a system. A=B no yes if(c == 100) P=20 P=80 else p= 80 while(p>20) dummy print(student mark) yes no Print

Flow Chart versus Structure Chart z. A structure chart differs from a flow chart Flow Chart versus Structure Chart z. A structure chart differs from a flow chart in three principal ways: y. It is difficult to identify modules of a software from its flow chart representation. y. Data interchange among the modules is not represented in a flow chart. y. Sequential ordering of tasks inherent in a flow chart is suppressed in a structure chart.

Transformation of a DFD Model into Structure Chart z. Two strategies exist to guide Transformation of a DFD Model into Structure Chart z. Two strategies exist to guide transformation of a DFD into a structure chart: y. Transform Analysis y. Transaction Analysis

Transform Analysis z. The first step in transform analysis: ydivide the DFD into 3 Transform Analysis z. The first step in transform analysis: ydivide the DFD into 3 types of parts: xinput, xlogical processing, xoutput.

Transform Analysis z. Input portion in the DFD: yprocesses which convert input data from Transform Analysis z. Input portion in the DFD: yprocesses which convert input data from physical to logical form. ye. g. read characters from the terminal and store in internal tables or lists. z. Each input portion: ycalled an afferent branch. y. Possible to have more than one afferent branch in a DFD.

Transform Analysis z. Output portion of a DFD: ytransforms output data from logical form Transform Analysis z. Output portion of a DFD: ytransforms output data from logical form to physical form. xe. g. , from list or array into output characters. y. Each output portion: xcalled an efferent branch. z. The remaining portions of a DFD ycalled central transform

Transform Analysis z. Derive structure chart by drawing one functional component for: ythe central Transform Analysis z. Derive structure chart by drawing one functional component for: ythe central transform, yeach afferent branch, yeach efferent branch.

Transform Analysis z Identifying the highest level input and output transforms: yrequires experience and Transform Analysis z Identifying the highest level input and output transforms: yrequires experience and skill. z Some guidelines: ytrace the inputs until a bubble is found whose output cannot be deduced from the inputs alone. y. Processes which validate input are not central transforms. y. Processes which sort input or filter data from it are.

Transform Analysis z. First level of structure chart: ydraw a box for each input Transform Analysis z. First level of structure chart: ydraw a box for each input and output units ya box for the central transform. z. Next, refine the structure chart: yadd subfunctions required by each high-level module. y. Many levels of modules may required to be added.

Factoring z. The process of breaking functional components into subcomponents. z. Factoring includes adding: Factoring z. The process of breaking functional components into subcomponents. z. Factoring includes adding: yread and write modules, yerror-handling modules, yinitialization and termination modules, etc. z. Finally check: ywhether all bubbles have been mapped to modules.

Example 1: RMS Calculating Software Data-items User Compute. RMS 0 result Context Diagram Example 1: RMS Calculating Software Data-items User Compute. RMS 0 result Context Diagram

Example 1: RMS Calculating Software z. From a cursory analysis of the problem description, Example 1: RMS Calculating Software z. From a cursory analysis of the problem description, yeasy to see that the system needs to perform: xaccept the input numbers from the user, xvalidate the numbers, xcalculate the root mean square of the input numbers, xdisplay the result.

Example 1: RMS Calculating Software numbers Readnumbers 0. 1 Validatenumbers 0. 2 Data-items error Example 1: RMS Calculating Software numbers Readnumbers 0. 1 Validatenumbers 0. 2 Data-items error Computerms 0. 3 Display 0. 4 result Valid numbers RMS

Example 1: RMS Calculating Software z. By observing the level 1 DFD: yidentify read-number Example 1: RMS Calculating Software z. By observing the level 1 DFD: yidentify read-number and validate-number bubbles as the afferent branch ydisplay as the efferent branch.

Example 1: RMS Calculating Software root rms Valid-numbers Get-good-data Get-data Compute-solution Validate-data rms Display-solution Example 1: RMS Calculating Software root rms Valid-numbers Get-good-data Get-data Compute-solution Validate-data rms Display-solution

Example 2: Tic-Tac-Toe Computer Game z As soon as either of the human player Example 2: Tic-Tac-Toe Computer Game z As soon as either of the human player or the computer wins, ya message congratulating the winner should be displayed. z If neither player manages to get three consecutive marks along a straight line, yand all the squares on the board are filled up, ythen the game is drawn. z The computer always tries to win a game.

Context Diagram for Example 2 display Tic-tac-toe software 0 move Human Player Context Diagram for Example 2 display Tic-tac-toe software 0 move Human Player

Level 1 DFD move Validatemove Displayboard Playmove game result Checkwinner Level 1 DFD move Validatemove Displayboard Playmove game result Checkwinner

Structure Chart root Get-good-move Get-move Compute-game Validatemove play-move Display Checkwinner Structure Chart root Get-good-move Get-move Compute-game Validatemove play-move Display Checkwinner

Transaction Analysis z. Useful for designing transaction processing programs. y. Transform-centered systems: xcharacterized by Transaction Analysis z. Useful for designing transaction processing programs. y. Transform-centered systems: xcharacterized by similar processing steps for every data item processed by input, process, and output bubbles. y. Transaction-driven systems, xone of several possible paths through the DFD is traversed depending upon the input data value.

Transaction Analysis z Transaction: yany input data value that triggers an action: y. For Transaction Analysis z Transaction: yany input data value that triggers an action: y. For example, selected menu options might trigger different functions. y. Represented by a tag identifying its type. z Transaction analysis uses this tag to divide the system into: yseveral transaction modules yone transaction-center module.

Transaction analysis Transactioncenter trans 1 type 1 trans 3 trans 2 type 3 Transaction analysis Transactioncenter trans 1 type 1 trans 3 trans 2 type 3

Level 1 DFD for TAS Customer-history Customer-file order Item-file Acceptorder Accepted-orders query inventory statistics Level 1 DFD for TAS Customer-history Customer-file order Item-file Acceptorder Accepted-orders query inventory statistics Handlequery Processorder Vendor-list Indent-request Indents Handleindentrequest Sales-statistics pending-order

Structure Chart order Handle-order Get-order root indent Handle-indent Accept-order Processorder query Handle-query Structure Chart order Handle-order Get-order root indent Handle-indent Accept-order Processorder query Handle-query

Summary z We first discussed structured analysis of a larger problem. z We defined Summary z We first discussed structured analysis of a larger problem. z We defined some general guidelines yfor constructing a satisfactory DFD model. z The DFD model though simple and useful ydoes have several short comings. z We then started discussing structured design.

Summary z. Aim of structured design: ytransform a DFD representation into a structure chart. Summary z. Aim of structured design: ytransform a DFD representation into a structure chart. z. Structure chart represents: ymodule structure yinteraction among different modules, yprocedural aspects are not represented.

Summary z. Structured design provides two strategies to transform a DFD into a structure Summary z. Structured design provides two strategies to transform a DFD into a structure chart: y. Transform Analysis y. Transaction Analysis

Summary z. We Discussed three examples of structured design. z. It takes a lot Summary z. We Discussed three examples of structured design. z. It takes a lot of practice to become a good software designer: y. Please try to solve all the problems listed in your assignment sheet, y not only the ones you are expected to submit.