Download presentation
Presentation is loading. Please wait.
Published byJoshua Barton Modified over 10 years ago
1
Programming Techniques1 POWER OF LOGIC Programming Techniques “CHI BEN COMINCIA E’ A META’ DELL’OPERA” Cutajar and Cutajar
2
Programming Techniques2 When you write a program you are solving a problem. To solve the problem you must derive a solution To derive a solution you must use your powers of logic When you write a program you are solving a problem. To solve the problem you must derive a solution To derive a solution you must use your powers of logic POWER OF LOGIC
3
Programming Techniques3 STEPS IN PROGRAMMING Objectives (of program from system specification) Writing the instructions in a programming language Testing and Debugging Writing up the program documentation Implementation (putting the program into action) Program planning and design
4
Programming Techniques4 OBJECTIVES IN WRITING PROGRAMS Objectives define what the program must do! The resultant program should be : (WORKABLE) RELIABLE: must always do what it is supposed to do. oROBUST: program does not crash under exceptional circumstances. (PERFORMANCE) EFFICIENT: must do it fast and efficiently. READABLE: easy to read and understand by others. MAINTAINABLE: Easy to update and debug. PORTABLE: easily transferable to another type of machine. STORAGE SAVING: ideally must occupy as little memory as possible.
5
Programming Techniques5 PROGRAM PLANNING AND DESIGN Structured Programming is a term embodying methods of writing programs which are clear in their construction, easy to read and maintain, easy to write and test Structured programming methods Top Down Modular Design Bottom Up Modular Design Stepwise Refinement methods Stepwise Refinement methods
6
Programming Techniques6 A module is a self-contained subprogram, which performs independently one specific function (task). Advantages in using modules Re-usability Easier to read, debug and maintain (update) Natural division of work Remark Modules can be compiled separately Driver program is required to further test modules MODULARITY PROCESSING Input ONE entry point Output ONE exit point
7
Programming Techniques7 TOP-DOWN MODULAR APPROACH Problem is broken down into a number of components (modules). Each component is progressively decomposed into smaller, more manageable components until each component can be easily understood. Problem Module A Module A [1] … Module A [n] Module B Module B [1] … Module B [n] Module A1 [1] … Module B1 [1] …
8
Programming Techniques8 Individual manageable modules are initially identified; progressively these are combined to form larger modules until the original problem request is fully carried out. Method recommendable only in the case of experienced programmers and the existence of a library of previously developed modules BOTTOM-UP MODULAR APPROACH Module 1 Module 2 Module i-1 Module i Module A Module B Original Problem
9
Programming Techniques9 EXAMPLE: PROCESSING EXAM RESULTS A teacher wants to process some exam results: PROCESS Output Input Candidate’s name Index number Mark (out 100) Passmark >= 40 Credit >= 70 A value of –1 terminates input Percentage of candidates failing, passing, obtaining a credit Name Index number Message : Fail, Pass or Credit Percentage candidates Fail, Pass or Credit
10
Programming Techniques10 HIERARCHICAL INPUT PROCESS OUTPUT (HIPO) CHART (TO TEACHER’S CAUSE) Top down approach to solving teacher’s exam results problem: Prepare Examination Results Input DetailsProcess DetailsOutput Details Edit Input Validate input Determine Mark Category Determine Student Counts Print Individual Details Print Summary Print Error Listing
11
Programming Techniques11 BASIC FORMS OF ALGORITHM CONSTRUCTION. An Algorithm consists of a number of steps which, if followed, would result in the underlying task being carried out. Using structured programming any algorithm can be written using three basic logical constructs or the Jackson’s Structured Programming (JSP) Techniques Sequence Selection Iteration
12
Programming Techniques12 Sequence The execution of one instruction after another. Selection :(Branching) Nested selection allows the number of alternative paths to be arbitrary. SEQUENCE AND SELECTION Task ATask BTask C Test ? Task A Task B TRUE FALSE
13
Programming Techniques13 ITERATION: (LOOPING, REPETITION) The power of iteration: A process of indeterminate duration is described by an algorithm of finite length.
14
Programming Techniques14 EXPRESSING ALGORITHMS. Some ways of expressing instruction flow independently of any programming language: Pseudocode (Program) Flow charts
15
Programming Techniques15 PSEUDOCODE English-like statements very close to high-level language statements. Example 1: Given variables x and y, required to swap their contents temp x x y y temp Example 2: Given input number x, required to check whether even or odd. If x mod 2 = 0 Then output message ‘even’ Else output message ‘odd’ Example 3: Required to display integer numbers from 1 to 10. i 0 while i <= 10 do i i+1 … display the value of i endwhile
16
Programming Techniques16 FLOWCHARTS Program flowcharts show a sequence of (algorithmic) steps in pictorial form. Some BASIC SYMBOLS used in program flowcharting: Start/End Process Input/output Decision Predefined Process Connector Flow in process
17
Programming Techniques17 EXAMPLE: FLOWCHART OF EXAM RESULT PROCESS Y Start Input Name,index,Mark Is Mark = -1? Is Mark<40? Is Mark<70? Total Count T = F+P+C Increment Credit count C=C+1 Increment Pass count P=P+1 Increment Fail count F=F+1 End N Y N N Y SAMPLE PROGRAM FLOWCHART SAMPLE PROGRAM FLOWCHART Print Index number Print “FAIL”Print “PASS” Print “CREDIT” Print F/T*100% P/T*100% C/T*100%
18
Programming Techniques18 WRITING THE INSTRUCTIONS IN A PROGRAMMING LANGUAGE (CODING) Most time-consuming stage Requires a lot of effort (hence expensive) Aids to save time and money using existing library routines, subroutines and subprograms other programming aids such as oscreen painting software, oreport generators, oapplication generators, oRAD (Rapid Application Development) tools.
19
Programming Techniques19 TESTING AND DEBUGGING THE PROGRAM Program Errors : A program may have any or all of four types of errors: Syntax Errors: A statement in the program violates a rule of the language, Semantic Errors: Violating rules of language, semantic errors are concerned with the meaning of language statements (semantics). Logical Errors: The program runs to completion but gives wrong results or performs wrongly in some way. Runtime Errors: Program crashes during execution. The translator detects syntax and semantic errors but the translator does NOT detect Logical and Run-time errors. These require rigorous testing for detection and correction.
20
Programming Techniques20 DEBUGGING PROGRAMS Aids and techniques: single stepping through the program setting breakpoints displaying contents of specified variables in memory dumping and examining the contents of a file dumping and examining the entire contents of memory
21
Programming Techniques21 STAGES OF TESTING May be quite a lengthy and expensive process. Stages of testing: Desk–checking /Dry run Unit testing Module testing Subsystem testing System testing User acceptance testing o(Alpha testing in the case of bespoke software) o(Beta testing in the case of packaged product)
22
Programming Techniques22 TYPES OF TESTING There are two ways of approaching testing : Functional Testing (Black box testing) Based on typical, extreme and invalid data values that are representative of those covered by the specification. Logical Testing (White box testing) Based on examining the internal structure of the program and selecting data which gives rise to the alternative cases of control flow. Remarks: Functional testing is not adequate by itself. Logical testing by the programmer during program development is most effective.
23
Programming Techniques23 SELECTING TEST CASES Every statement in the program is executed at least once. The effectiveness of all sections of code that detect invalid input is tested. The accuracy of all processing is verified. The program operates according to its original design specifications.
24
Programming Techniques24 TEST DATA CATEGORIES Normal/valid data – data the program is designed to handle. Extreme/critical values – valid data at the limits of acceptability. exceptional/invalid data – attempt to enter invalid data should not crash the program or give wrong results.
25
Programming Techniques25 STAGES OF PROGRAM TESTING: Unit testing: subprograms (components) need to be individually tested to ensure that they conform to specifications. Module testing: when combined to form a program, modules must be tested to ensure that these (components) do not act in unexpected ways. System/Subsystem testing: when the whole set of programs must be tested to ensure that they integrate correctly. User acceptance testing: When the user of the program (possibly the customer) tests the program to see that it is what is required.
26
Programming Techniques26 PROGRAM MAINTENANCE Program maintenance implies modification of the program. MAINTENANCE may be: Adaptive maintenance due to identified new requirements Corrective maintenance due to identified errors Perfective maintenance due to identified improvements to the existing set up. Aids to maintenance: Modular design Use of structured programming techniques Readable Code Good Documentation
27
Programming Techniques27 WRITING UP THE PROGRAM DOCUMENTATION Program Documentation contents: A description of the problem to be solved. A program abstract that describes the various tasks which the program performs (the files used, etc). Operating instructions on how to run the program. A summary of the program controls which are built into the program. A test plan and data used to test the program for accuracy. Any changes made during testing should be recorded.
28
Programming Techniques28 DOCUMENTATION TYPES AND PRESENTATIONS Documentation may be presented in different forms: Manuals Online help Documentation types: User Manual Operations manual Technical Manual (program listing includes inline documentation)
29
Programming Techniques29 USER MANUAL Typical information in a user manual: Overview of options available Guidance on the sequence of operations to follow Screen shots showing screen input forms Instructions on how to enter data Sample report layouts Error messages that may be displayed and what action to take
30
Programming Techniques30 OPERATIONS MANUAL Documentation of procedures necessary to run the system. Typical information: System setup procedures, including details for each application of the files required and consumables requirements Security procedures Recovery procedures in the event of system failure A list of system messages that might appear on the operator’s console and what action to take
31
Programming Techniques31 TECHNICAL MANUAL Typical information in a technical manual include: Overall system plan Data organisation and flow Full annotated listing Details of test data and results
32
Programming Techniques32 IMPLEMENTATION (PUTTING THE PROGRAM INTO ACTION) Implementation phase may include a number of activities: acquisition of new hardware and its installation. oWhen installing new hardware, this may involve extensive re-cabling and changes in office layouts. Training the users on the new system Conversion of master files to the new system, or creation of new master files.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.