%Error Types and Debugging

%Two major types of errors
%Syntax errors - grammar, spelling, wrong number of arguments

%Easy to fix: Modern editors will highlight errors or warnings (in MATLAB
%errors are underlined in red and warnings are underlined in yellow)

%On program crash: the Command Window provides a line number of the code
%that just executed

%Semantic errors - logical errors, errors in meaning, program runs but it
%doesn't performed what is intended

%Harder to fix - Editor's don't know what the programmer wants, so they
%can't identify issues

%To solve these issues:
%Programmer needs to know the correct behavior of each piece of code
%Need to know what the contents of variables should be throughout the
%execution

%Debugging - done to methodically finding where errors are in code
%Debugging Techniques:
% Incremental coding - code in small pieces, test each piece individually
% to build up to the larger program
% Comment out portions of code
% Display messages and variable names while the code is running (add print
% statements or disp statements)
% Find smallest (or simplest) example that causes the problem
% Use a debugger

%A debugger a programming tool that assists in debugging code
%Basic functionality:
% Set breakpoints (stop execution & wait)
% Step through (execute) code line by line
%   Step over (skip over execution of a function), into (go into a
%   function), out of (go out of a function)
% Allows you to view key variables using the workspace when code is waiting