warnings – issues identified by the compiler that MIGHT CAUSE PROBLEMS or have UNINTENDED SIDE-EFFECTS on running application
errors – issues identified by the compiler that MUST BE FIXED prior to running application
logic error:a bug in a program that causes it to operate incorrectly, but not to terminate abnormally
runtime errors: issues that occur while your application is running – these can be logic errors or errors that cause application to crash
software bug: an error, flaw, failure, or fault in a computer program or system that causes it to produce an incorrect or unexpected result, or to behave in unintended ways
static errors: issues identified by the compiler that must be fixed prior to running application
warning: issues that might cause problems or have unintended side-effects on running application
Reproduce the problem -> Gather debug information -> what is the value of a variable? what kind of error?
logs, program state, …
=> Form a Hypothesis
print debugging
-only use print statements to debug
extension PrintBugViewController { override func canBecomeFirstResponder() -> Bool { return true } override func motionEnded(motion: UIEventSubtype, withEvent event: UIEvent){ if motion == .MotionShake { disperseBugsAnimation() } } func handleSingTap(recognizer: UITapGestureRecognizer) { addBugToView() } }
func addBugToView(){
println(self)
if bugs.count < maxBugs {
let newBug = bugFactory.createBug()
bugs.append(newBug)
view.addSubview(newBug)
moveBugsAnimation()
}
println(self)
}
func emptyBugsFormView(){
for bug in self.bugs {
bug.removeFromSuperview()
}
}
extension PrintBugViewController : Printable,
DebugPrintable {
override var description: String {
return "PrintBugViewController contains \(bugs.count) bugs\n"
}
}[/code]