Structured Programming - Lecture 1
Structured Programming - Lecture 1
PROGRAMMING
A. A. Datti
COURSE OUTLINE
•Introduction to Structured Programming
•What is functional programming?
•Benefits of functional programming
•Functional vs. Object-oriented programming
•Functions, Closures and scopes
•Understanding your application’s control flow
•Method chaining and Function chaining
•Reasoning about your code
•Learning to think recursively
SWE4205 - STRUCTURED PROGRAMMING 2
INTRODUCTION TO
STRUCTURED Lecture1
•Part of the reason for this is that nobody knew how to design a good high-
level language, nor did they know how to write a compiler to generate
efficient code.
•These basic blocks have only one entry point and one exit point. Control of
which basic blocks are executed, and in what order, is accomplished with
highly structured flow control statements.
For example, consider a function for translating time of day from 24-hour format
into conventional AM-PM format. This can be done by implementing the task as a
sequence of 3 subtasks.
•If a program is spaghetti code, then the flow of control is difficult to follow, much
more likely to have bugs, and is extremely difficult to debug. If the flow of control
is too complex for the programmer to follow, then it cannot be adequately
debugged.
SWE4205 - STRUCTURED PROGRAMMING 9
“SPAGHETTI CODE”
oThat problem led Edsger Djikstra to speculate that the GOTO statement in
the procedural languages of the time led to poor programming practice. In
essence, the overuse of jumps as a means of altering sequence had led many
commercial programs into a “rat’s nest” of unmaintainable applications and
dead-end processing.
SWE4205 - STRUCTURED PROGRAMMING 12
STRUCTURED PROGRAMMING
AS A SOLUTION
oDjikstra’s idea led to the evolution of the concept that the structured
programming theorem was a solution to the “spaghetti code” problem.