Please enable JavaScript.
Coggle requires JavaScript to display documents.
2.2.1 Programming Techniques - Coggle Diagram
2.2.1 Programming Techniques
3 Basic Programming constructs
Branching
- Can
choose
which instructions is done next based on something that happens while program is executed (
IF/ELSE/ELIF
)
Iteration
- Used to execute same instruction a
num. of times
until condition met - loops (
WHILE/FOR
)
Sequence
- Instructions executed in
order
- from beginning going through each line until finished
IDE
IDE (i
ntegrated development environment
) used to
write code
,
test for errors
+
translate a program
- the
features
are:
Breakpoints
- Points in code where program can be
stopped
to see what's
happening/check for errors
- created by programmer to halt program after a certain num. of lines of code
Automatic Error Checking
- Automatically
checks code
by itself +
shows errors
to the user
Debugging
- Program in IDE used to detect errors. If debugger detects errors, suggest type of error + line
Stepping Through
- Stepping is method of debugging which executes the code
one line at a time
to check for errors.
Error Reports
- If there is an error it will
detect
it and may gave the type of error (
syntax, runtime, logical
) and line
Nesting/Variables
Nesting
- placing
one construct within another
Variable
-
Named location
in memory that programmer can use to
store data
while program is running
Local Var.
- Only be
accessed by subroutine
they were declared in
Global Var.
- Available
throughout program
to any subroutine. Declared at the start after any imported libraries – difficult to follow and debug if declared after start
Recursion/Iteration
Advantage
of recursion is people think recursively, happier applying same procedure to different info a set num. of times - makes recursion code
easier to understand
Drawback
– uses a lot of memory. Every time function calls itself a copy is made in memory. (
iteration
)– has loops so values of existing variables are
updated
Both uses similar num of lines
Recursion
repeatedly
calls itself
until a base case is made
Iteration
- Used to execute same instruction a
num. of times
until condition met - loops (
WHILE/FOR
)
Function/Procedures
Function
is a block of organized,
reusable code
that is used to perform a single, related action
Procedure
is a set of
coded instructions
that tell a computer how to
run a program
or calculation
Functions
can have only
input parameters
for it -
procedures
can have
input/output parameters
.