L01 - Basics of Structured Programming
L01 - Basics of Structured Programming
L01 - Basics of Structured Programming
https://online.husson.edu/software-development-cycle/
Software Development Method
• Requirement Specification
– Problem Definition
• Analysis
– Refine, Generalize, Decompose the problem definition
• Design
– Develop Algorithm
• Implementation
– Write Code (Programming)
• Verification and Testing
– Test and Debug the code
Computer Programming
• The functions of a computer system are
controlled by computer programs
• A computer program is a clear, step-by-step,
finite set of instructions
• A computer program must be clear so that only
one meaning can be derived from it
• A computer program is written in a computer
language called a programming language
A Question?
• Do you know the number of programming
languages exist?
• Imagine the number
• https://en.wikipedia.org/wiki/List_of_programmin
g_languages
Terms
• It is interesting and useful to investigate the meaning
of the word 'paradigm‘
Terms
• Programming paradigm (in this course)
– A pattern that serves as a school of thoughts for programming of
computers
• Programming technique
– Related to an algorithmic idea for solving a particular class of problems
– Examples: 'Divide and conquer' and 'program development by stepwise
refinement'
• Programming style
– The way we express ourselves in a computer program
– Related to elegance or lack of elegance
• Programming culture
– The totality of programming behavior, which often is tightly related to a
family of programming languages
– The sum of a main paradigm, programming styles, and certain
programming techniques.
Definitions
• Programming Paradigm
– programming “technique” (?)
– way of thinking about programming
– view of a program
• Programming Language
– consists of words, symbols, and rules for writing a
program
Programming Paradigms
• Main programming paradigms
– The imperative paradigm
– The functional paradigm
– The logical paradigm
– The object-oriented paradigm
• Other possible programming paradigms
– The visual paradigm
– One of the parallel paradigms
– The constraint based paradigm
Programming (Language) Paradigms
Disadvantages
difficulty of reasoning about programs
difficulty of parallelization
Tend to be relatively low level
Structured Programming
• Structured programming is a programming
paradigm aimed at improving the clarity, quality,
and development time of a computer program by
making extensive use of
– subroutines,
– block structures,
– for and while loops
• in contrast to using simple tests and jumps such
as the goto statement, which could lead to
"spaghetti code" that is difficult to follow and
maintain
Elements of Structured Programming
• Control structures
– "Sequence"; ordered statements or subroutines executed in
sequence.
– "Selection"; one or a number of statements is executed
depending on the state of the program (if..then..else..endif).
– "Iteration"; a statement or block is executed until the program
reaches a certain state, or operations have been applied to
every element of a collection (for, while loop).
– "Recursion"; a statement is executed by repeatedly calling itself
until termination conditions are met.
Elements of Structured Programming
• Subroutines
– callable units such as procedures, functions,
methods, or subprograms are used to allow a
sequence to be referred to by a single statement
• Blocks
– are used to enable groups of statements to be treated
as if they were one statement.
•Block-structured languages have a syntax for enclosing
structures in some formal way, such as the curly braces {...} of
C and many later languages.
Programming Paradigms: Object-Oriented
Disadvantages
Can have a steep learning curve, initially
Doing I/O can be cumbersome
Programming Paradigms: Functional
•Assembly Language
– E.g. add overtime to base pay and store result in gross pay
LOAD BASEPAY
ADD OVERPAY
STORE GROSSPAY
Programming languages
• High-level languages
Disadvantages
Not portable
Not programmer friendly
Assembly Language
Languages with features from different paradigms are often too complex.