DebuggingTemplate
DebuggingTemplate
Is your code
Steps to missing semicolon , missing
colo
'Compilation/ Syntax Error'
compiling No
has occured Fix Errors typo in reserved/keywor
incorrect braces closing or
successfully? indentation error
- Link mismatch/ absence in function
return type and return
statemen
How to identify:
incorrect impor
Compilation failed because of undeclared variable
‘Wrong Syntax’ and an error End of File error
message appears which helps
identify the error.
Yes
this error
Steps to
Division by zer
Accessing array out of its limi
Null pointer exceptio
Is your program
crashing? Yes 'Runtime Error' has occurred Fix Errors Memory/stack overflow/
segmentation faul
- Link
Variable casting error
Index Out Of Bound Exception -
check edge cases and data
type overflow and sizes (if
How to Identify:
code is in C++ or Java)
The indicator of runtime error
is - No/ Invalid Output with an
error message
No
Yes
Is the output
matching your
expected output/ Yes Good to Go. No more Errors!
all your test cases
are passing?
No
Is the program
Iscrashing/
the program
Steps to
Yes crashing/ throwing an
throwing an
exception?
No 'Logical Error' has occurred What type of test cases are failing Fix Errors
exception?
How to Identify:
- Link
We see a difference in expected vs
actual output. Invalid/ Incorrect
Output
Note:
STEPS TO FIX
COMPILATION/ SYNTAX
ERRORS
Read the error message. The error message would ideally clearly call out the error along with the line number in most of the cases.
Try the fix in this section and run your code again
STEPS TO FIX
RUNTIME ERRORS
Understand the Error Message: The programming language usually provides an error message or exception stack trace giving
information about the error's type and location. Read and understand the error message to identify the cause of the error. Google the
error message if needed.
calculations, null references, or recursive functions that may be causing the error.
Fix the Error: Once the cause of the error is identified, make the necessary modifications to fix the issue. It could involve adding
conditional checks, handling exceptions, validating input, or adjusting algorithmic logic.
How to fix:
applicable).
or flawed algorithms
2. For the Time limit exceeded -
conditions.
STEPS TO FIX
LOGICAL
ERRORS
Review the Code: Carefully examine the code and algorithm to understand the expected behavior and the logic implemented. Look for any
discrepancies between the intended logic and the actual code. Eg. Are you missing out on a possible set of scenarios
Use Debugging Techniques: Utilize debugging techniques, such as adding print statements or using a debugger, to track the flow of execution,
Print statements can be added in the sections of the code where a decision is being made. (PS- If the logical bits are segregated into
functions, it becomes easier to debug if a function is working as expected and giving the correct result
One can print expected outputs in a print statement or some indicative values to check if the code is reaching till a particular section/line
numbe
Comment out sections of the code: which you think might be causing an error to identify the code section which is working correctly if adding
In case of absence of a compiler usage to test above 2 steps, one can consider an input test case (along with the expected output) and
manually check the code flow for actual output one is getting through a code walkthrough vs. expected output. (Video can be created to
Check the input values and the corresponding output to identify any patterns or inconsistencies that may reveal logical errors. Consider
edge cases and ensure the algorithm handles all scenarios correctly. Use Custom runs to get 'actual output' from your code vs 'expected
output'
Modify the Logic: Once identified, make the necessary adjustments to the code or algorithm to fix the issue. Update the program logic to
Test and Rerun the code with various inputs to ensure the the logical error is resolved and the program produces the correct output.
compiling successfully?’