Scaffolding
Scaffolding Code
Print Statements
Adding print statements in strategic locations within the code to display the values of variables, intermediate results, or messages. This helps to track the program flow and identify potential issues.
Logging
Incorporating logging statements into the code to record important information or events during program execution. Log files can provide valuable insights into the flow and behavior of the code.
Debuggers
Debuggers & Tracebacks
Debuggers
Using a debugger tool integrated into the development environment to step through the code, set breakpoints, inspect variables, and analyze program execution. Debuggers allow you to pause the program at specific points and examine its state.
Tracebacks and Error Messages
Examining error messages or tracebacks provided by the programming language or runtime environment. They often provide valuable information about the nature and location of the error.
Code Instrumentation
Adding additional code or hooks to collect data or measure performance. This can help identify specific sections of code that may be causing issues or impacting performance.
Code Review
Code Review
Engaging colleagues or peers to review your code for potential errors, logic flaws, or alternative perspectives. Fresh eyes can often spot issues that may have been overlooked.
Rubber Duck Debugging
Explaining the code and the problem to an inanimate object (like a rubber duck) or a colleague. The act of verbalizing the problem often helps to identify the root cause or a potential solution.
Divide & Conquer
Divide and Conquer
Narrowing down the problem area by systematically isolating sections of code and testing them individually. This approach helps identify the specific code block responsible for the issue.
Binary Search Method
If the problem is related to a large dataset or complex calculation, using a binary search technique to narrow down the problematic area. This involves repeatedly dividing the dataset or code block in half and testing each section until the problem is identified.
Unit Testing
Unit Testing
Writing and executing focused tests for individual units or functions of the code. This approach allows for systematic testing and helps identify issues early in the development process. If also means that different individuals or teams can be given responsibility for testing different modules or areas of the program.