Programming Paradigms Flashcards
(15 cards)
What are programming paradigms?
Approaches to programming
What are the two main paradigms in programming?
1) Functional programming
2) Imperative programming
What is functional programming?
Programming that has no variables, and instead uses functions as mappings from one value to another
What is imperative programming?
Programming that has commands that the computer performs in a specific sequence
What are the two main types of imperative programming?
1) Procedural programming
2) Object-Oriented programming
What is procedural programming?
Type of imperative programming where programs are made up of imperative commands that are run sequentially
- Uses sequence, selection and iteration
- Broken up into smaller parts or modules using subroutines
What is object-oriented programming?
An entirely modular to programming where everything in the program is implemented as an object which has attributes and properties (data) and methods (subroutines)
- Data and code that acts on the data are kept together and controlled via methods that comprise the interface
What does the structural approach to programming involve?
1) Organise programs into subroutines and modules by using hierarchy charts to break a program down
2) Store data in variables and constants with meaningful identifiers
3) Program to the interface by using subroutines
4) Use local variables instead of global variables
5) Use indentation, spacing and comments to make code easier to follow
What are the advantages to the structured approach?
- Subroutines and modules can be individually tested
- Modules with related subroutines make it easy to navigate for developers
- Indented code is easier to read
- Comments can explain how program works to other developers
- Meaningful identifiers make it easier to follow
- Parameters and return values to pass values into and out of subroutines reduces likelihood for errors
What is a hierarchy chart?
- A diagram showing the structure of a program using a top-down approach
- Breaks system down layer-by-layer into components and processes
- Each box contains a label / description for each process
What are the advantages of subroutines?
- Each subroutine can be tested separately
- Meaningful identifiers make the code easier to understand
- Code easily reused
- Easier to maintain as code only needs to be changed once within the subroutine
What is a procedure?
A subroutine that does not return a value
What is a function?
A subroutine that return a value
How can you tell if a variable is a constant?
Named with all capital letters e.g. EMPTYSTRING
What is a local and global variable?
- A local variable is declared in a subroutine or similar
- A global variable is declared at the highest possible level in a program so that it can be used in any lower level statements