Part 5, Modular Programming Flashcards

1
Q

what is modular programming also known as

A

modular programming is also known as component based programming

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

explain what modular programming is

A

modular programming means splitting a program up into smaller modules or components

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

name four main benefits of modular programming

A
  1. easier to create
  2. less error prone
  3. readability
  4. reusability (in same or external program)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

why are modular programs easier to create

A

modular programs are easier to create because they can be worked on in small independent sections. ultimately these “sections” or components will make up a tiny piece of the program

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

why are modular programs less prone to error

A

modular programs are less prone to error because each component can be created and tested one piece at a time this greatly reduces bugs being created within the program.

modular programs also have the benefit of aiding in debugging because each component can be tested individually

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

why are modular programs easier to understand

A

because modular programs are broken up into smaller subtasks this makes reading the code easier. and following the stream of execution much more obvious

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

what are three main rules for a module when implementing modular programming

A
  1. a module should have a specific and meaningful task
  2. the name of the module should reflect what the module does
  3. modules should be commented
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

what five pieces of information might be given in a modules comment/specification

A
  1. explain what the module does
  2. explain how its inputs are used
  3. explain any variables it sets
  4. give information of any dependencies it has
  5. give an example of it in action
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

what is a pre condition

A

a pre condition is a condition that must be met in order for a module to operate correctly

this must be mentioned within its specification

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

“number_input must be in numbers_list”

is written within a modules comments and is part of its specification

what is this an example of

A

“number_input must be in numbers_list”

is an example of a modules pre condition

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

your told to factor out a chunk of code within your program

what does the term “factor out” mean

A

“factor out” means taking a block of code out of the main script and creating a separate subtask/module for it. without changing what the script does

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

what is meant by re factoring code

A

re factoring code means rewriting/restructuring code to make it simpler to read or more efficient without changing what the program does

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

what does the term monolithic mean

A

monolithic is a term used to describe code that is written in a non modular fashion

this means the code may all be written within one script

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

what are 5 possible drawbacks of monolithic code

A

monolithic code can be

  1. lengthy
  2. complicated
  3. prone to errors
  4. harder to code
  5. low readability
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

when designing the algorithm from the specification you see that modular programming may be helpful

how can you show that you will be using modular programming within the algorithm

A

when you spot a subtask that can be a module

  1. mark the subtask {subtask 1} for example
  2. write out the specification for the subtask in a separate box
  3. keep the subtask marked in main algorithm with an arrow pointing to its boxed specification
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

your implementing your algorithm using the “bottom-up approach”

what does this mean

A

when implementing your algorithm “bottom-up approach” means to build the components that have no dependencies first. then build components with dependencies only when their dependencies have been built

17
Q

what is an example of a module having a dependency

A

when a module relies on data created by another module this means it has a dependency on that module

as a rule if a module is passed data or relies on data to work then it has a dependency and the modules creating the data should be built first
hence why there is a bottom-up approach
18
Q

your ready for testing and your program contains many components what is the first stage of testing your program

A

if your program contains many components then each component should be tested individually before testing the program as a whole

19
Q

when testing a component name four things to remember

A
  1. test different inputs
  2. test for expected outputs
  3. check it conforms to its specification
  4. include variable names within the test table