Presentation is loading. Please wait.

Presentation is loading. Please wait.

The Programming Discipline Professor Stephen K. Kwan 2010 Things you need to know (learn) for developing large computer programs.

Similar presentations


Presentation on theme: "The Programming Discipline Professor Stephen K. Kwan 2010 Things you need to know (learn) for developing large computer programs."— Presentation transcript:

1 The Programming Discipline Professor Stephen K. Kwan 2010 Things you need to know (learn) for developing large computer programs.

2 1.The Programming Project – problem statement, purpose & scope 2.The Problem Solution Approach – algorithms 3.Diagrammatic Aids 4.The Operating Environment 5.Choosing the Programming Language – grammar (syntax and semantics), Text/GUI, purpose 6.The Primitives of the Language – objects, variables, data types, declarations, numbers, strings, etc.

3 8.The Input/Output (I/O) System 9.Arithmetic Expressions and Assignment Statements 10.Decision Making and Logical Expressions 11.Support of Structured Programming Techniques 12.Functions and Subroutines - modules 13.Event-based Programming for GUIs, Interface Design 14. Internal Storage - Arrays and Data Structures 15. External Storage - Files and Databases

4 16. Error Detection and Handling 17. Input Validation 18.Output Verification and Formatting 19. Debugging and various levels of testing 20. Projects and Programming Tasks 21. Operational issues – compile/link/execute 22. Deployment, Version Control, etc.

5 Structured Programming Techniques Motivation: We need help in dealing with large programs The Halting Problem for Programs, that is, The Halting Problem for Programs, that is, the problem as to whether a given program with given input ever halts, is recursively undecidable (proof). proof Must avoid “spaghetti code” Must avoid “spaghetti code” More

6 Structured Programming Techniques Step-wise refinement to “ organize the computation in such a way that our limited powers are sufficient to guarantee that the computation will establish the desired effect.” Edsgar W. Dijkstra, “Notes on Structured Programming”, in Dahl, Dijkstra and Hoare, Structured Programming, Academic Press, 1972.

7 Structured Programming Techniques “If the chance of correctness of an individual component equals p, the chance of correctness of a whole program, composed on N such components, is something like P = p N As N will be very large, p should be very, very close to 1 if we desire P to differ significantly from zero!”

8 Structured Programming Techniques Adopt the following techniques: Block 1Block 2Block 3 Sequence Each Block has one Entrance and one Exit “GO-TO-less”

9 Structured Programming Techniques Block 1 Block 2 Repetition Condition While Condition Is True Do Block 1 Do Block 2 Until Condition Is True T F T F Each Block has one Entrance and one Exit

10 Structured Programming Techniques Block 1 Selection Condition IF-THEN-ELSE TF Each Block has one Entrance and one Exit Block 2 Block 1 Condition T F IF-THEN

11 Structured Programming Techniques Block N Selection Variable CASE OF Each Block has one Entrance and one Exit Block 2Block 1 :::: = 1= 2= N

12 Example

13 Javascript Examples if (condition) { code to be executed if true} else { code to be executed if false } if (condition1) { code to be executed if condition1 is true } else if (condition 2) { code to be executed if condition 1 is false and condition 2 is true } else { code to be executed if condition 1 and 2 are both false }

14 Javascript Examples for (var = startvalue; var <= endvalue; var = var + increment) { code to be executed } code to be executed var <= endvalue var = startvalue var = var + increment F T Another form of classic While Do loop while (condition) { code to be executed }

15 Javascript Examples do { code to be executed } while (condition) code to be executed condition F T Note that this is similar to the classic Do Until loop except the condition is reversed do { code to be executed } while ( ! condition) This will become the classic Do Until loop

16 Javascript Examples switch ( n ) { case 1: ……… break; case 2: ……… break; : default: …….. }

17 Issues with Structured Programming Techniques Regardless of whether the programming language represents data as objects or not, we should employ Structured Programming Techniques in constructing procedural code. System Designs often undergo a lot of changes System Designs often undergo a lot of changes Event-based programming for GUI usually involve small modules of code in response to user- initiated events Event-based programming for GUI usually involve small modules of code in response to user- initiated events Structured Programming Techniques only deals with procedural code, does not deal with data that are acted upon by the program – this is addressed by object-oriented programming languages Structured Programming Techniques only deals with procedural code, does not deal with data that are acted upon by the program – this is addressed by object-oriented programming languages End


Download ppt "The Programming Discipline Professor Stephen K. Kwan 2010 Things you need to know (learn) for developing large computer programs."

Similar presentations


Ads by Google