WK6: Debugging and Coding Standards (Session 1)

Welcome to Week 6
Debugging Exercises and Coding Standards
Module Lecturer: Dr Raghav Kovvuri
Email: raghav.kovvuri@ieg.ac.uk

1 / 9
volgende
Slide 1: Tekstslide
ProgrammingHigher Education (degree)

In deze les zitten 9 slides, met tekstslides.

Onderdelen in deze les

Welcome to Week 6
Debugging Exercises and Coding Standards
Module Lecturer: Dr Raghav Kovvuri
Email: raghav.kovvuri@ieg.ac.uk

Slide 1 - Tekstslide

Recap
What is debugging?
  • Process of finding and fixing errors
Importance of coding standards
  • Improves readability and maintainability
  • Facilitates collaboration
  • Reduces errors and debugging time
Key elements of coding standards:
  • Consistent naming conventions
  • Proper indentation and formatting
  • Meaningful comments and document

Slide 2 - Tekstslide

Debugging Exercise 1 
Exercise 1 - Weather Prediction System
  • Download Weather_Prediction.py and run debugger in VSCode
Tasks:
  1. Identify and fix the bugs in this code
  2. Apply proper coding standards (naming, indentation, comments)
  3. Add meaningful comments to explain the code's functionality

Slide 3 - Tekstslide

 Debugging Techniques 
  • Using print statements
  • Utilizing IDE debugging tools
  • Step-through debugging
  • Breakpoints
  • Proper code documentation:
            Function docstrings
            Inline comments for complex logic
            Module-level comments

Slide 4 - Tekstslide

Debugging Exercise 2
Exercise 2 - Data Processing System
  • Download DataProcessor.py and run debugger in VSCode
Tasks:
  1. Debug this code using IDE tools
  2. Apply consistent naming conventions (e.g., snake_case for functions and variables)
  3. Add docstrings to classes and methods
  4. Include inline comments for complex operations

Slide 5 - Tekstslide

Common Debugging Pitfalls and Code Quality
Debugging Pitfalls
  • Assuming the bug is where you think it is
  • Ignoring compiler warnings
  • Not testing fixes thoroughly
  • Debugging the symptoms, not the cause
  • Forgetting to remove debugging code
  • Poor code quality leading to bugs:
             Inconsistent naming
             Lack of comments
             Overly complex functions

Slide 6 - Tekstslide

Best Practices for Debugging
  1. Write clear, self-documenting code
           Use meaningful variable and function names
  2. Use version control
           Track changes and revert if needed
  3. Take breaks and get fresh eyes
           Sometimes stepping away helps you see the                       problem
  4. Rubber duck debugging
           Explain your code to an inanimate object (or                       person)

Slide 7 - Tekstslide

Next Session
Programming Workshop
Scenario: Smart City Traffic Light System
  • Download Programming Workshop.pdf from Canvas

Slide 8 - Tekstslide

Slide 9 - Tekstslide