Exploring debugging
My code has bugs in it. Your code has bugs in it. We’re not bad coders; all code has bugs – we just haven’t found them all yet. According to Coverity (a code-quality scanning company), quality-controlled professionally written software has around 1 defect (or bug) per 1,000 lines of code. Some of these bugs are never found because the particular set of rare circumstances where the code doesn’t behave as expected (an edge case, in the jargon) hasn’t occurred.
Bugs largely consist of two types:
- Syntax errors, where we’ve misspelled a cmdlet or parameter name or missed out a closing bracket or quotation mark. Syntax errors are basically typing errors – just sometimes we’ve typed the wrong thing thinking it’s the right thing. We’ve seen already how using VS Code can help us enormously with this, by color coding, syntax checking, code hints, and tab autocomplete.
- Logic errors, where...