Programming Techniques Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q
  1. What is a scope?
A

Scope refers to the section of code where the variable is available

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

Why local variables can’t be accessed by other subroutines?

A

Local variables have limited scope and can thus only be accessed within the block of code in which they are defined

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

What are the benefits of using local variables?

A

It is considered good practice to use local variables in subroutines so they different parts of the code are self-contained and not affected by referencing variables with the same name outside of the blocks of code.

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

What is the use of global variables?

A

Global variables can be used anywhere in the main body, hence variables declared in the main body are by default global.

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

Cons of using global variables?

A

Cons: they can be overwritten and edited unintentionally, they require memory as they are never deleted until the program ends

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

Which will take precedence a global or a local variable?

A

A local variable will always take precedence over a global one

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

How do you implement modular programming?

A

Modular programming is a programming technique used to split large, complex programs into smaller, self-contained modules that can be split within a team, making a problem easier to understand and approach, simplifying the process of testing and maintenance by isolating each module.

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

Pros of implementing modular programming?

A

Pros: modules that are tested can be reused

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

What in common do procedures and functions have?

A

Procedures and functions are named block of codes that perform a certain task

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

What differs procedures from functions?

A

Procedures do not have to return a value or can return multiple values, functions must return one single value. Procedures are usually given data as parameters, while functions make use of local variables

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

What are the 2 ways that parameters are passed into a subroutine?

A

When parameters are passed in a subroutine, they are passed byVal or byRef

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

Describe what happens when passing a parameter by Val?

A

Passing a parameter byVal means that it is treated as a local variable, a copy of the value is passed to the subroutine and then discarded at the end, so the value outside of the subroutine is not affected

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

Describe what happens when passing a parameter by Ref?

A

Passing a parameter byRef means that the address of the parameter is passed into subroutine, hence the value will be updated at the given address

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

What is an IDE?

A

An Integrated Development Environment, or IDE, is a program which provides a set of tools to make it easier for programmers to write, develop and debug code.

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

What are the 5 common features of an IDE?

Scope refers to the section of code where the variable is available

A

Common features of IDEs include:

a. Stepping allowing you to monitor the effect of each individual line of code by executing a single line at a time
b. Variable watch which is sometimes used to pinpoint errors, this is a useful feature to observe how the contents of a variable change in real-time through the execution of a program. 
c. Breakpoint IDEs which allows users to set a point in the program at which the program will stop, helping to pinpoint where an error is occurring.
d. Source code editor which aims to make the coding process easier by providing features such as autocompletion of words, indentation, syntax highlighting and automatic bracket completion. 
e. Debugging tools: IDEs also provide run-time detection of errors with a guide as to where in the code they are likely to have occurred through line numbers and highlighting
How well did you know this?
1
Not at all
2
3
4
5
Perfectly