110 likes | 351 Views
The Programming Discipline Things you need to know (learn) for developing large computer programs. Professor Stephen K. Kwan The Programming Project – problem statement, purpose & scope The Problem Solution Approach – algorithms Diagrammatic Aids The Operating Environment
E N D
The Programming Discipline Things you need to know (learn) for developing large computer programs. Professor Stephen K. Kwan
The Programming Project – problem statement, purpose & scope • The Problem Solution Approach – algorithms • Diagrammatic Aids • The Operating Environment • Choosing the Programming Language – grammar (syntax and semantics), Text/GUI, purpose • The Primitives of the Language – objects, variables, data types, declarations, numbers, strings, etc.
The Input/Output (I/O) System • Arithmetic Expressions and Assignment Statements • Decision Making and Logical Expressions • Support of Structured Programming Techniques • Functions and Subroutines - modules • Event-based Programming for GUIs, Interface Design • Internal Storage - Arrays and Data Structures • External Storage - Files and Databases
Error Detection and Handling • Input Validation • Output Formatting • Debugging and various levels of testing • Projects and Programming Tasks • Operational issues – compile/link/execute • Deployment, Version Control, etc.
Structured Programming Techniques Motivation: More • We need help in dealing with large programs • The Halting Problem for Programs, that is, • the problem as to whether a given program with given input ever halts, is recursively undecidable (proof). • Must avoid “spaghetti code”
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.
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 = pN As N will be very large, p should be very, very close to 1 if we desire P to differ significantly from zero!”
Structured Programming Techniques Adopt the following techniques: Sequence Block 1 Block 2 Block 3 “GO-TO-less” Each Block has one Entrance and one Exit
Structured Programming Techniques Repetition While Relation Is True Do Block 1 Do Block 2 Until Relation Is True Relation F Block 2 T Block 1 F Relation T Each Block has one Entrance and one Exit
Structured Programming Techniques Selection IF-THEN-ELSE CASE OF T Relation F Variable = 1 = 2 = N Block 1 Block 2 Block 1 Block 2 Block N :::: Each Block has one Entrance and one Exit
Issues with Structured Programming Techniques • 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 • 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 Regardless of whether the programming language represents data as objects or not, we should employ Structured Programming Techniques in constructing procedural code. End