Procedural programming paradigm(1.2.4 b) Flashcards
What is the procedural programming paradigm?
where code is made up of seperate blocks of code that do a specific task called procedures
What is structured prgramming?
using the fundamental programming constructs sequencing selection and iteration
What does the term spaghetti code mean?
the goto command used to be used to manually direct the flow of the program and the code was so interconnected it was really hard to follow
What is procedural programming?
built on the idea that all code can be broken down into the three programming constructs, procedural takes this idea a step further by reducing long programs into a series of subroutines
Procedural programs
should have single point of entry
encourages programmer to think about what a program does
Procedural programs subroutine form
many languages use in form of subroutine
called main which is automatically called when program is run
main subroutine then calls other subroutines to execute the programs main tasks
What happens if the subroutine has meaningful identifiers?
the main function is self-documenting
Why is procedural programs sometimes called top down problem solving?
as we start with a large problem and break it down into smaller discrete subproblems which can be solved independently
key part of modular design
Benefits of procedural programming
easier to test and debug as fewer lines of code to trace through
subroutines can be called many times reducing amount of repeating code
subroutines can manipulate shared data (global variables)
code is reusable as subroutines can be saved in libraries and imported into programs when needed
very large programs can be worked on by a whole team of programmers who can develop subroutines concurrently so that a project can be completed faster
Drawbacks of procedural programming
focuses on what needs to be done rather than on the integrity of the data that it manipulates
global variables often can cause issues with data integrity
nothing in the procedural paradigm that truly protects data
data is passed into subroutines used and sometimes modified and the programmer must be fully aware of what they should and shouldn’t do and abide by the rules of good practice to ensure data integrity