1 / 45

Programming Methods (CT)

Programming Methods (CT). Chapter 3 SECTION B DATA ANALYSIS AND PROBLEMS. Chapter CONTENTS:. Analyzing problems Designing a top-down modular program Determining the structure of a programm from a given specification Structured Programming diagrams CRC cards.

inge
Télécharger la présentation

Programming Methods (CT)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Programming Methods (CT) Chapter 3SECTION BDATA ANALYSIS AND PROBLEMS

  2. Chapter CONTENTS: • Analyzing problems • Designing a top-down modular program • Determining the structure of a programm from a given specification • Structured Programming diagrams • CRC cards

  3. Chapter 3SECTION BData Analysis and Problems PART 1Analyzing the Problem

  4. 1.1 Analysing the Problem • Insist on a proper program specification • Analyse the problem • Break down the problem down • E.g. how to fix/change a flat tire

  5. Hospital information System Transaction DB (Doctors + Patient, Payments) Personnel DB (Nurses, Doctors, etc) Patients DB (Emergency, OPD, etc) Inventory DB (Drugs, Medical Equipments) Example : Hospital Information System Module and Sub-modules

  6. 1.3 Definitions of Key Terms Top-down Development • An approach to program development in which is made by: • defining required elements in terms of basic elements • beginning with the required program and ending when implementation language is reached • At every stage during the top-down development, each of the undefined elements from the previous stage is defined. • Stepwise refinement (enhancement) • An approach to software development in which an initial, highly abstract representation of a required program is gradually refined through a sequence of intermediate representations.

  7. 1.3 Definitions of Key Terms (cont) Program Decomposition • The breaking down of a complete program into a set of component parts called modules. • E.g. Visual Basic Procedures • Modular Programming • A style of programming in which complete program is decomposed into a set of components (called modules) • E.g. VB Module (illustrate) • manageable size • has well defined purpose • has a well defined interface for use by other modules

  8. 1.4 Designing a Top-down Modular Program • One module contains the instructions that supply the top-down logic for the whole program • This module contains the three basic functions: • Initilialising • Processing • Closing down the program

  9. 1.5 Examples of Initialization Routines • Requesting library routines • E.g. include <stdio.h> (C Language) • Opening file • Defining headings, creating opening screen • Initialising variables • E.g. Dim x as Integer, name as String (VB Language)

  10. 1.6 Examples of Processing Tasks • Input • reading records from a file • requesting data from the user • Computation and logic • comparing values • computations • assignments • Output • updating files • writing records to a file • printing a report • displaying information on screen

  11. 1.7 Examples of Closing Tasks • Producing printed output • Writing a file • Printing final totals in a report • Displaying final user messages • Closing all open files

  12. NOTE: • JSP addresses the these different requirements: • Reading records from a file • Processing the element of an array • Repeating procedures from a lower level in the diagram 1.8 Jackson Structured Programming (JSP) - Iteration • Hierarchical diagrams can be used to illustrate a method of problem solving. • But there must be way (for these diagram to be useful) of showing sequence, selection and iteration

  13. 1.9 Jackson Structured Programming - Iteration

  14. NOTE: • Reading records until the End of File (EOF) • Illustrate VB program example 1.10 Jackson Structured Programming (JSP)- Example 1

  15. NOTE: • Continue processing until user types stop. 1.11 Jackson Structured Programming (JSP)- Example 2

  16. NOTE: • In this technique is to write the conditions above or below each box to be chosen results of the selection and insert an ‘0’ in the top right corner of the box. 1.12 Jackson Structured Programming (JSP) You must also make a selection of such tasks such as: • Choosing an alternative procedure at a lower level • Taking actions according to the results of the entries • Making comparisons and acting on the result

  17. NOTE: • Jackson Structure Diagram showing convention for selection • Illustrate VB program example 1.12 Jackson Structured Programming (JSP)- Example 3

  18. 1.13 Determining the Structure of a Program • Program is designed from the program specification SCENARIO: Assessment Results • Program is to read a file of records of a students name • Six examination marks (integer value) • Calculate average mark • Assessed grade • FAIL, which is >39 and <=39 • PASS, which is >39 and <=59 • MERIT, which is >59 and ,<79 • DISTINCTION, which is >79 • Result to be written on new file • Each record should contain • name, average, percentage mark and grade • On termination print students whom examination marks have been processed

  19. 1.13 Determining the Structure of a Program (cont.) • The program can be separated into components initialization tasks, processing tasks and closing tasks.

  20. STEP 1: • Initialising : Open files • Processing : Process each record to find grades • Closing : Close files 1.14 Stepwise Refinement – Step 1 • Outline requirements for each component

  21. STEP 2: • Initialising refinement : open file for reading and writing • Processing refinement : set up lop to read in and process each record • Closing refinement: close files, output closing message 1.15 Stepwise Refinement – Step 2 • They can be further divided to give each of the following refinements

  22. STEP 3: Processing of the records • calculate the mean • establish the grade • write the results to a file • count the number of records 1.16 Stepwise Refinement – Step 3 • No further refinement needed for initialisation or termination • Further analysis of the processing tasks is needed

  23. 1.16 Stepwise Refinement – Step 3 (cont.)

  24. 1.16 Stepwise Refinement – Step 4 • Actions required to complete the diagram are easily determined • Calculate average • Accumulate marks • Divide the total number of marks (6) • Assign result average variable • Assess grade • Compare average with grade boundaries • Write result to grade variable • Write to file • Write name variable + average mark + grade variable record • Accumulate number of records • Make sure this running total is at zero ate the beginning of the program

  25. 1.17 Jackson Structured Programming • This technique • Uses a top-down stepwise refinement • Uses only three control structures • Bases the program design on the structure of the data to be processed • The steps are: • From the program specification, produce data structure diagrams of the data to be input for the processing and output • Produce a program structure which reflects the requirements of the data structures • Analyse this in a top-down manner to produce a more increasingly more specific program structure.

  26. NOTE: • A stock record is organized into sections by content (children's clothes, men's clothes, and women’s clothes). The data on children's clothes is to be extracted 1.18 JSP Example 1 – Physical Data Structure

  27. NOTE: • The logical data structure reflects that no processing. 1.19 JSP Example 1 – Logical Data Structure

  28. NOTE: Physical data structure diagram of transaction file • A transaction file has been created by inputting the information on sales and purchases in batches. • Each batch has a header record followed by records with the details of sales and purchases. • The batches of records are input as they are received and therefore can occur in any order. 1.20 JSP Example 2 – Physical Data Structure

  29. NOTE: Logical data structure diagram of transaction file • If sales report is required (no reference to purchases) which shows totals for both cash and credit sales as shown above. • Every record will no longer be processes and the purchases will be ignored. 1.21 JSP Example 2 – Logical Data Structure

  30. 1.22 Establishing the Program Structure Criteria: • Determine the input and output data structures • The output requirements are a great help in determining the logical structure of a file. • Combining them to produce the program structure • The example is process is illustrated is on the next slide

  31. 1.23 Example 1 : Using One Input File to Produce One Output File or Report Physical and Logical DSDs

  32. NOTE: • The report structure is to have a heading, a on-line summary of the total order value for each garage, and a footer containing the total of all orders. 1.24 Example 1 : Continued.. Physical DSD - Report

  33. 1.25 Example 1 : Continued.. Comparison of Physical DSDs

  34. 1.26 Example 1 : Continued.. Comparison of Logical DSDs of Input and Output

  35. 1.27 Comparison of Logical DSDs of Input and Output (cont.) Explanation of Previous Slide • The output requirement does not need to include the area of each garage • The logical DSD of the input files, do not need to include this component.

  36. NOTE: PSD Properties • Each data component is relatedonly to one programcomponent. • Each program component is related only to one input and/or one out component. 1.28 Program Structure

  37. Chapter 3Data Analysis and Problems PART 2CRC Diagrams

  38. 2.1 What are CRC Cards? CRC Cards stands for: • Class • Responsibility • Collaboration • Created in the late 1980s as a method to teachobject oriented paradigm

  39. 2.2 What are CRC Cards? (cont..) • CRC cards aimed to find a way to express a system in an abstract way that was analogous to structured programming. • CRC cards are brainstorming tool used when first determining which classes are needed and how they will interact.

  40. 2.3 Advantages of CRC Based Modelling There are many advantages in using a CRC- based modelling • Creates a good understanding of the domain to be modelled • It identifies high level of responsibilities • It ensures better system design • It ensures that knowledge of the domain is shared by anyone • A good working can be developed • It is a good way to identify areas that maybe missed otherwise • It is a fun

  41. 2.4 CRC Finding Classes and Considering Scenarios • Participants need to know what the requirements of the system will be • Brainstorming • the major classes for the system are identified • Individual classes can then be discussed and refined until a set is agreed • The group then considers scenarios likely to occur, to test the classes some will be discarded, others will become subclasses • A subclassis a class within a class • sharing some of the attributes and behaviors of its parent, but having attributes and behaviors of its own

  42. 2.5 CRC Method • A CRC card session should involve about five or six people • include people who have a detailed understanding of the system to be developed • Begin with a brainstorming session • usually someone oversees the session, recording suggestions on a flipchart/board • these suggestions form the basis of the classes for the system • Next, the classes suggested are discussed in detail and some will be filtered out

  43. 2.6 CRC Method (cont.) • Each class is written on a card, and assigned to a participant • a short description can be added on the back of the card, which can be read out to the group for approval • Next, the group considers simple scenarios which are likely to occur • helps to discover any missing classes, and the relationships that objects have to each other • Scenarios involve a discussion of how the classes behave and how they interact with each other

  44. FINAL NOTE: • To facilitate better understanding of all of these methods, techniques and methodologies, you are advised to work through the Self Study Section and Exercises at the end each Chapter on your Textbook. Chapter SUMMARY In this Chapter we have covered: • Program development process • Structure diagrams • Organizing information • Fixed and variable length record • Analyzing the problem • Structured programming diagrams • CRC cards introduction including scenarios, role play and method

More Related