Intro to debugging theoy

Let’s talk for a moment about software debugging theory. In general, software errors (also known as “bugs”) can be categorized as follows:
  • Compile-Time Errors
  • Run-Time Errors
  • Logical Errors

Compile-Time Errors

As the name implies, a compile-time error occurs when you attempt to compile your application source code. In Xcode, this happens when you select “Build and Run” or “Build and Debug” in order to launch your application on the device or simulator. When a compile-time error is encountered, it will literally prevent your application from being launched. As we will see, errors in this category may either occur from nonsensical or incorrect syntax statements or from problems that arise in the linking phase of your application build. Generally speaking, compile-time errors are the easiest of the three categories to resolve because the compiler will typically issue a meaningful error message or warning message that will alert you to the nature of the problem.

Run-Time Errors

Run-time errors occur after your application has been compiled and launched in the Simulator or on a device. An application crash or memory leak that occurs as the result of poor object memory management is an example of a run-time error.

Logical Errors

A logical error occurs during the run-time phase of an application and results in unexpected or undesired application behavior that conflicts with the software developer’s or project stakeholder’s intended outcome. A good example of a logical error is a mathematical formula that has been implemented incorrectly. Consider the Pythagorean theorem:
Pythagorean Theorem Formula
If a software developer unintentionally implemented this formula as:
Wrong equation
The result would be a logical error, but it most likely would not cause the application to crash. That is what makes logical errors so hazardous: the application may seemingly run “bug free” to the developer while in fact producing invalid or undesirable output.