SlideShare une entreprise Scribd logo
1  sur  36
Télécharger pour lire hors ligne
Bug Hunting Safari!
Janie Clayton-Hasz
Why is Debugging Hard?
• We all know we should debug, but many people
don’t know how to do it well.
• Our community does not have an overly broad
knowledge base about doing in-depth debugging
because it’s hard to make time to learn it better.
• We like to think that we can write all of our code
perfectly without any mistakes, but unfortunately
that is not the case, no matter how hard we try.
– Crow T. Robot from Mystery Science Theater 3000 for those under the age
of thirty or over the age of fifty
“Well, believe me, Mike, I calculated
the odds of this succeeding versus
the odds I was doing something
incredibly stupid… and I went
ahead anyway…”
Why is Learning Efficient
Debugging Important?
• Depending on the source, it is reported that a
professional programmer spends only 1/6 of their
time coding. Most sources agree that half of your
time as a programmer will be spent debugging
yours and other people’s code.
• Learning tools, tricks, and common problems will
free up more of your time so you can code rather
than debug!
Why is Learning Efficient
Debugging Important?
• At some point in your career, you will be working on
code that you did not write yourself. The previous
person will do things differently than you would
have and you need to be able to figure out why
something you did not write works and breaks.
• You will continue to grow and mature as a
developer. Looking at code you did three months
ago can be painful and you probably won’t
remember what you did or why.
Setting up Your
Debugging Environment
Why Have a Debugging
Environment??
• Everything you do in work and in life is better when
you have a dedicated set-up for it. Look at your
kitchen. You have a dedicated space to doing a
specific task and everything is arranged to make
that as easy as possible
• You have, or should have, a dedicated coding
space to help you focus and be productive. If you
want to be a productive debugger, you need to
care about setting up your space and your tools.
Debugging Console
• Create a dedicated debugging tab
• Make sure your bottom view is exposed
• Can set many things to optimize debugging in
XcodePreferencesBehaviors
NSLog(): First Line of
Defense!
NSLog()
• NSLog() is a function that you can use to print a
message to your console.
• NSLog() is a development tool. Nothing printed
using NSLog() is seen by the user
• Usually used to print out variables to the console in
order to check their value and to ensure they are set
• First type of debugging most people learn how to
do
Breakpoints!
Thing I accidentally make
when I click on an error
message that makes my
program stop running.
Flavors of Breakpoints
• Breakpoint Logging
• Exception Breakpoints
• Conditional Breakpoints
• Symbolic Breakpoints
• Watchpoints
Advantages of Breakpoints
• Easier to clear out of production code than NSLog()
statements. You should not include NSLog()
statements in an app that is submitted to the App
Store
• More flexible than adding code to your project for
debugging
• Less likely to generate errors because you are not
adding additional code to your project
Breakpoint Logging
Logging with Breakpoints
• Think back to when you were creating all those
NSLog() statements. They were kind of messy,
weren’t they?
• You can use breakpoints to do the same thing
Exception Breakpoint
When Do You Use an
Exception Breakpoint?
• Have you ever built and run your application only to
have it crash and direct you to the Main.m file? You
know the problem isn’t there because you haven’t
touched it. How do you find out where the problem
actually is?
• You use an Exception Breakpoint
Exception Breakpoint
• What happens with Xcode is that when it
encounters a problem in your code, it will keep
going until it crashes. That is why it usually stops in
the incredibly unhelpful Main.m class rather than
where the problem actually is.
• By creating an exception breakpoint, you are telling
Xcode you want it to stop where the problem is
rather than to keep going and crash somewhere
else.
Conditional Breakpoints
Conditional Breakpoint
• You are telling Xcode to stop if a condition is not
met.
• The condition must equate down to a true or a
false.
• You can use this in a loop if you need to know what
the result of a certain iteration is by setting “Ignore
’n’ times before stopping.”
Watchpoint
Who Watches the
Watchpoints?
• Watchpoints are a tool you can use to keep an eye
on any object that is going to undergo a change.
• For example, if you have a label that is updated by
input from the user, you can set a watchpoint on it.
Symbolic Breakpoint
Symbolic Breakpoints
• Used any time a specific method type is called.
• For example, if you want to know every time the
view loads you can create a symbolic breakpoint to
do something when viewDidLoad is called.
LLDB: Or How I
Stopped Worrying and
Learned to Love the
Command Line
What is LLDB?
• All of the tools we have been working with so far
are written in LLDB.
• LLDB uses a command line interface.
• Anything you did in Xcode, like setting a
breakpoint, can be done on the command line in
the debugging console.
Why Would I Want to Know
LLDB?
• LLDB has more functionality than what has been
built into the user interface in Xcode.
• Writing code in the command line is faster and
more efficient than having to use the mouse to
move around selecting user interface elements.
• You can do debugging in the terminal and bypass
Xcode completely. If you want to use something
like AppCode, this is a way to use LLDB.
Why Would I Want to Know
LLDB?
• You can customize LLDB commands to suit your
projects more closely
• You can extend LLDB’s functionality with the use of
Python Scripts
Creative Way to Torture
Your Coworkers
Sound Breakpoints!!
• You can program a breakpoint to generate a sound
when something happens.
• When you go on vacation, program all of your
breakpoints to make annoying sounds when the
program is running. Your less knowledgeable
coworkers will go crazy figuring out where the
sound is coming from!! BWHAHAHA!!!
In Conclusion…
99 little bugs in the code!
99 little bugs!
You take one down,
You patch it around!
117 little bugs in the code!
Bugs are bad. You do not want bugs. You do
not want to ship an app that has bugs. Bugs
are the number one reason that apps are
rejected from the App Store.
!
Bugs happen. You don’t want to ignore little
bugs…
Because they become
BIG BUGS!!
`

Contenu connexe

Tendances

iOS Automated Testing with Calabash: Tips and Tricks
iOS Automated Testing with Calabash: Tips and TricksiOS Automated Testing with Calabash: Tips and Tricks
iOS Automated Testing with Calabash: Tips and Tricks
mobiletestsummit
 

Tendances (14)

Pp informatica
Pp informaticaPp informatica
Pp informatica
 
Lecture 31
Lecture 31Lecture 31
Lecture 31
 
Most valuable software design principles
Most valuable software design principlesMost valuable software design principles
Most valuable software design principles
 
iOS Automated Testing with Calabash: Tips and Tricks
iOS Automated Testing with Calabash: Tips and TricksiOS Automated Testing with Calabash: Tips and Tricks
iOS Automated Testing with Calabash: Tips and Tricks
 
Code smells and Other Malodorous Software Odors
Code smells and Other Malodorous Software OdorsCode smells and Other Malodorous Software Odors
Code smells and Other Malodorous Software Odors
 
A UX Manifesto
A UX ManifestoA UX Manifesto
A UX Manifesto
 
Programming
ProgrammingProgramming
Programming
 
Front end and back end storyboarding
Front end and back end storyboardingFront end and back end storyboarding
Front end and back end storyboarding
 
Lecture 30
Lecture 30Lecture 30
Lecture 30
 
Two heads are better: the benefits of pair writing
Two heads are better: the benefits of pair writingTwo heads are better: the benefits of pair writing
Two heads are better: the benefits of pair writing
 
AATC2016: Exploratory testing an API
AATC2016: Exploratory testing an APIAATC2016: Exploratory testing an API
AATC2016: Exploratory testing an API
 
Terminal Happiness
Terminal HappinessTerminal Happiness
Terminal Happiness
 
Enterprise Strength Mobile JavaScript
Enterprise Strength Mobile JavaScriptEnterprise Strength Mobile JavaScript
Enterprise Strength Mobile JavaScript
 
7 things to sabotage an agile coach camp
7 things to sabotage an agile coach camp7 things to sabotage an agile coach camp
7 things to sabotage an agile coach camp
 

Similaire à Bug Hunting Safari

Software Development Essential Skills
Software Development Essential SkillsSoftware Development Essential Skills
Software Development Essential Skills
John Choi
 
Driving application development through behavior driven development
Driving application development through behavior driven developmentDriving application development through behavior driven development
Driving application development through behavior driven development
Einar Ingebrigtsen
 

Similaire à Bug Hunting Safari (20)

PHP - Introduction to PHP Bugs - Debugging
PHP -  Introduction to  PHP Bugs - DebuggingPHP -  Introduction to  PHP Bugs - Debugging
PHP - Introduction to PHP Bugs - Debugging
 
Software Development Essential Skills
Software Development Essential SkillsSoftware Development Essential Skills
Software Development Essential Skills
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
 
Developers Best Practices
Developers Best PracticesDevelopers Best Practices
Developers Best Practices
 
Software Development Whats & Whys
Software Development Whats & Whys Software Development Whats & Whys
Software Development Whats & Whys
 
11 rules for programmer should live by
11 rules for programmer should live by11 rules for programmer should live by
11 rules for programmer should live by
 
CNIT 126 Ch 9: OllyDbg
CNIT 126 Ch 9: OllyDbgCNIT 126 Ch 9: OllyDbg
CNIT 126 Ch 9: OllyDbg
 
Traits of a Good Engineer
Traits of a Good EngineerTraits of a Good Engineer
Traits of a Good Engineer
 
Things You Need to Know Before Starting An App-Openair2015 keynote
Things You Need to Know Before Starting An App-Openair2015 keynoteThings You Need to Know Before Starting An App-Openair2015 keynote
Things You Need to Know Before Starting An App-Openair2015 keynote
 
Software testing and quality assurance
Software testing and quality assuranceSoftware testing and quality assurance
Software testing and quality assurance
 
Spaghetti gate
Spaghetti gateSpaghetti gate
Spaghetti gate
 
Prototyping Accessibility - WordCamp Europe 2018
Prototyping Accessibility - WordCamp Europe 2018Prototyping Accessibility - WordCamp Europe 2018
Prototyping Accessibility - WordCamp Europe 2018
 
The Good, the Bad and the Ugly things to do with android
The Good, the Bad and the Ugly things to do with androidThe Good, the Bad and the Ugly things to do with android
The Good, the Bad and the Ugly things to do with android
 
Computer programming
Computer programmingComputer programming
Computer programming
 
Notes on Debugging
Notes on DebuggingNotes on Debugging
Notes on Debugging
 
Practical Malware Analysis: Ch 9: OllyDbg
Practical Malware Analysis: Ch 9: OllyDbgPractical Malware Analysis: Ch 9: OllyDbg
Practical Malware Analysis: Ch 9: OllyDbg
 
9: OllyDbg
9: OllyDbg9: OllyDbg
9: OllyDbg
 
Preparing for the WebGeek DevCup
Preparing for the WebGeek DevCupPreparing for the WebGeek DevCup
Preparing for the WebGeek DevCup
 
Driving application development through behavior driven development
Driving application development through behavior driven developmentDriving application development through behavior driven development
Driving application development through behavior driven development
 
Getting better through Katas
Getting better through KatasGetting better through Katas
Getting better through Katas
 

Plus de Janie Clayton

Plus de Janie Clayton (11)

Robots in Swift
Robots in SwiftRobots in Swift
Robots in Swift
 
Beyond White: Embracing the iOS Design Aesthetic
Beyond White: Embracing the iOS Design AestheticBeyond White: Embracing the iOS Design Aesthetic
Beyond White: Embracing the iOS Design Aesthetic
 
Thinking In Swift
Thinking In SwiftThinking In Swift
Thinking In Swift
 
3D Math Primer: CocoaConf Chicago
3D Math Primer: CocoaConf Chicago3D Math Primer: CocoaConf Chicago
3D Math Primer: CocoaConf Chicago
 
GPU Programming: Chicago CocoaConf 2015
GPU Programming: Chicago CocoaConf 2015GPU Programming: Chicago CocoaConf 2015
GPU Programming: Chicago CocoaConf 2015
 
3D Math Primer: CocoaConf Atlanta
3D Math Primer: CocoaConf Atlanta3D Math Primer: CocoaConf Atlanta
3D Math Primer: CocoaConf Atlanta
 
GPU Programming: CocoaConf Atlanta
GPU Programming: CocoaConf AtlantaGPU Programming: CocoaConf Atlanta
GPU Programming: CocoaConf Atlanta
 
3D Math Without Presenter Notes
3D Math Without Presenter Notes3D Math Without Presenter Notes
3D Math Without Presenter Notes
 
The Day You Finally Use Algebra: A 3D Math Primer
The Day You Finally Use Algebra: A 3D Math PrimerThe Day You Finally Use Algebra: A 3D Math Primer
The Day You Finally Use Algebra: A 3D Math Primer
 
GPU Programming 360iDev
GPU Programming 360iDevGPU Programming 360iDev
GPU Programming 360iDev
 
Gpu Programming With GPUImage and Metal
Gpu Programming With GPUImage and MetalGpu Programming With GPUImage and Metal
Gpu Programming With GPUImage and Metal
 

Dernier

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Dernier (20)

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 

Bug Hunting Safari

  • 2. Why is Debugging Hard? • We all know we should debug, but many people don’t know how to do it well. • Our community does not have an overly broad knowledge base about doing in-depth debugging because it’s hard to make time to learn it better. • We like to think that we can write all of our code perfectly without any mistakes, but unfortunately that is not the case, no matter how hard we try.
  • 3. – Crow T. Robot from Mystery Science Theater 3000 for those under the age of thirty or over the age of fifty “Well, believe me, Mike, I calculated the odds of this succeeding versus the odds I was doing something incredibly stupid… and I went ahead anyway…”
  • 4. Why is Learning Efficient Debugging Important? • Depending on the source, it is reported that a professional programmer spends only 1/6 of their time coding. Most sources agree that half of your time as a programmer will be spent debugging yours and other people’s code. • Learning tools, tricks, and common problems will free up more of your time so you can code rather than debug!
  • 5. Why is Learning Efficient Debugging Important? • At some point in your career, you will be working on code that you did not write yourself. The previous person will do things differently than you would have and you need to be able to figure out why something you did not write works and breaks. • You will continue to grow and mature as a developer. Looking at code you did three months ago can be painful and you probably won’t remember what you did or why.
  • 7. Why Have a Debugging Environment?? • Everything you do in work and in life is better when you have a dedicated set-up for it. Look at your kitchen. You have a dedicated space to doing a specific task and everything is arranged to make that as easy as possible • You have, or should have, a dedicated coding space to help you focus and be productive. If you want to be a productive debugger, you need to care about setting up your space and your tools.
  • 8. Debugging Console • Create a dedicated debugging tab • Make sure your bottom view is exposed • Can set many things to optimize debugging in XcodePreferencesBehaviors
  • 9. NSLog(): First Line of Defense!
  • 10. NSLog() • NSLog() is a function that you can use to print a message to your console. • NSLog() is a development tool. Nothing printed using NSLog() is seen by the user • Usually used to print out variables to the console in order to check their value and to ensure they are set • First type of debugging most people learn how to do
  • 12. Thing I accidentally make when I click on an error message that makes my program stop running.
  • 13. Flavors of Breakpoints • Breakpoint Logging • Exception Breakpoints • Conditional Breakpoints • Symbolic Breakpoints • Watchpoints
  • 14. Advantages of Breakpoints • Easier to clear out of production code than NSLog() statements. You should not include NSLog() statements in an app that is submitted to the App Store • More flexible than adding code to your project for debugging • Less likely to generate errors because you are not adding additional code to your project
  • 16. Logging with Breakpoints • Think back to when you were creating all those NSLog() statements. They were kind of messy, weren’t they? • You can use breakpoints to do the same thing
  • 18. When Do You Use an Exception Breakpoint? • Have you ever built and run your application only to have it crash and direct you to the Main.m file? You know the problem isn’t there because you haven’t touched it. How do you find out where the problem actually is? • You use an Exception Breakpoint
  • 19. Exception Breakpoint • What happens with Xcode is that when it encounters a problem in your code, it will keep going until it crashes. That is why it usually stops in the incredibly unhelpful Main.m class rather than where the problem actually is. • By creating an exception breakpoint, you are telling Xcode you want it to stop where the problem is rather than to keep going and crash somewhere else.
  • 21. Conditional Breakpoint • You are telling Xcode to stop if a condition is not met. • The condition must equate down to a true or a false. • You can use this in a loop if you need to know what the result of a certain iteration is by setting “Ignore ’n’ times before stopping.”
  • 23. Who Watches the Watchpoints? • Watchpoints are a tool you can use to keep an eye on any object that is going to undergo a change. • For example, if you have a label that is updated by input from the user, you can set a watchpoint on it.
  • 25. Symbolic Breakpoints • Used any time a specific method type is called. • For example, if you want to know every time the view loads you can create a symbolic breakpoint to do something when viewDidLoad is called.
  • 26. LLDB: Or How I Stopped Worrying and Learned to Love the Command Line
  • 27. What is LLDB? • All of the tools we have been working with so far are written in LLDB. • LLDB uses a command line interface. • Anything you did in Xcode, like setting a breakpoint, can be done on the command line in the debugging console.
  • 28. Why Would I Want to Know LLDB? • LLDB has more functionality than what has been built into the user interface in Xcode. • Writing code in the command line is faster and more efficient than having to use the mouse to move around selecting user interface elements. • You can do debugging in the terminal and bypass Xcode completely. If you want to use something like AppCode, this is a way to use LLDB.
  • 29. Why Would I Want to Know LLDB? • You can customize LLDB commands to suit your projects more closely • You can extend LLDB’s functionality with the use of Python Scripts
  • 30. Creative Way to Torture Your Coworkers
  • 31. Sound Breakpoints!! • You can program a breakpoint to generate a sound when something happens. • When you go on vacation, program all of your breakpoints to make annoying sounds when the program is running. Your less knowledgeable coworkers will go crazy figuring out where the sound is coming from!! BWHAHAHA!!!
  • 33. 99 little bugs in the code! 99 little bugs! You take one down, You patch it around! 117 little bugs in the code!
  • 34. Bugs are bad. You do not want bugs. You do not want to ship an app that has bugs. Bugs are the number one reason that apps are rejected from the App Store. ! Bugs happen. You don’t want to ignore little bugs…
  • 36. `