Debugging in Context with Flowgorithm

When developing a solution to a problem in program code, we usually aim to write a bit of code that implements part of the solution and run it to see if works.

Bugs can start here, they manifest as errors that prevent your code from being compiled or executed out right, or produce incorrect results.

It’s important to note in our context that programs written in source code must be translated to machine code , which is directly executable by your computer’s CPU.

The translation can take place

  • with the entire file, that is, the entire source code compiled into executable code or
  • line by line, i.e a single line of source code is interpreted as machine code, then executed and so on.

Syntax , Logical and Runtime Errors

The errors or bugs experienced while we develop our code can be classified into three types:

  • Syntax – this is were the rules for structuring the code are broken, or not followed which prevents the translation process – this applies to both the compiler and interpreter which performs these tasks. The result of a syntax error is that the entire program cannot be executed. The programmer must fix the errors and try running the program again.
  • Logical – this is where the translation process completes successfully, but when the program is run it produces incorrect results or undesired behavior. After producing the logical error, the program continues to run indefinitely or until it stops by reaching the end of code produced by the programmer.

    For example, let’s say we were developing a solution that would prompt the user to enter 2 numbers, and output the sum, the following are some logical errors:
    • if the user entered 5.1 and 5, and the program outputs 10, this is an incorrect result
    • if the user entered 5.1 and 5, and the program doesn’t output anything – this is incorrect behavior
    • if the user entered 5.1 and 5, and the program continues to prompt the user to enter another and another indefinitely.
  • Runtime – this is where the program halts abruptly during execution and stops running (sometimes called a crash). It definitely passed the translation process, and can be run successfully in most cases (with or without logical errors), however some cases of user input or abnormal conditions of the computer system , the program crashes. Some reasons include:
    • the program attempts to divide by 0,
    • the program tries to access a memory location that it is not allowed to by the operating system
    • the operating system runs out of resources to provide to the program.

Video

Teacher Demonstration In class: bugs in Flowgorithm

© 2023  Vedesh Kungebeharry. All rights reserved. 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s