Find the Bug A Book of Incorrect Programs

Book description

50 exercises to help you find bugs faster -- with less aggravation!

Bug hunting is an art, and you need to be a master. Get Find the Bug, and you'll become one. Long-time Microsoft programmer Adam Barr presents 50 programs, each with exactly one bug. Your assignment: find it. As you do, Barr will teach you how to "think like your processor"... anticipating exactly how code will behave, even without running it. You'll learn better ways to read code, understand it -- and above all, improve it. Whether you're building new systems or maintaining someone else's, you'll find bugs earlier, faster, with less frustration... and write cleaner code to begin with.

  • Presents "bugged" programs in C, Java, Python, Perl, and x86 assembly language, with carefully explained solutions

  • Includes language overviews to help you debug all 50 examples, even if you don't know the language

  • Shows how to look past the "surface" of code to uncover its hidden internal logic

  • Offers practical guidance on analyzing programs, including specific inputs to test

  • Presents a wide range of realistic bugs, with no phony "gotchas"

  • Draws on the types of coding and debugging challenges Microsoft uses to interview new programmers

  • An indispensable resource for working programmers, maintainers, testers, quality specialists, and everyone involved in code reviews

© Copyright Pearson Education. All rights reserved.

Table of contents

  1. Copyright
  2. Acknowledgments
  3. About the Author
  4. Preface
  5. Bug Classification
  6. Tips on Walking Through Code
    1. Split the Code into Sections with Goals
    2. Identify the Meaning of Each Variable
    3. Look for Known Gotchas
    4. Choose Inputs for Walkthroughs
    5. Walk Through Each Section
    6. Summary
  7. C
    1. Brief Summary of C
    2. Selection Sort
    3. Linked List Insertion
    4. Linked List Removal
    5. Memory Copy
    6. Parse a String into Substrings
    7. Memory Allocator
    8. Memory Free
    9. Recursive Word Reversal
    10. Calculate All Possible Routes
    11. Kanji Backspace
  8. Python
    1. Brief Summary of Python
    2. Is a Number Prime?
    3. Find a Substring
    4. Alphabetize Words
    5. Encode Strings Using a Character Map
    6. Print the Month and Day
    7. Go Fish, Part I: Draw a Card from a Deck
    8. Go Fish, Part II: Ask if Another Hand Has a Card
    9. Go Fish, Part III: Play a Full Game
    10. Parse Numbers Written in English
    11. Assign Gift Givers
  9. Java
    1. Brief Summary of Java
    2. Is a Year a Leap Year?
    3. Convert a Number to Text
    4. Draw a Triangle on the Screen, Part I
    5. Draw a Triangle on the Screen, Part II
    6. Reverse a Linked List
    7. Check if a List Has a Loop
    8. Quicksort
    9. Play the Game Pong, Part I
    10. Play the Game Pong, Part II
    11. Compute Bowling Scores
  10. Perl
    1. Brief Summary of Perl
    2. Sort a File by Line Length
    3. Print the Prime Factors of a Number
    4. Tab Expansion
    5. Simple Database
    6. Find Repeating Part of a Fraction
    7. Expand Indented File List to Full Paths
    8. Sort All the Files in a Directory Tree
    9. Calculate Student Test Averages
    10. Merge Sort of Multiple Files
    11. Play the Game Mastermind
  11. x86 Assembly Language
    1. Brief Summary of x86 Assembly Language
    2. Make Change for a Dollar
    3. Multiply Two Numbers Using Shifts
    4. Join Strings with a Delimiter
    5. Calculate Fibonacci Numbers
    6. Check if Two Words Are Anagrams
    7. Convert a 64-Bit Number to a Decimal String
    8. Sum a Signed Array
    9. Play the Simulation Game Life
    10. Check if Parentheses Match in Source Code
    11. Radix Exchange Sort
  12. Classification of Bugs
    1. Syntax Versus Semantics
    2. Classification Used in This Book
    3. A–Algorithm
    4. D–Data
    5. F–Forgotten
    6. B–Blunder
    7. Summary
  13. Index of Bugs by Type
  14. References
    1. Classification of Bugs
    2. General Sources for Bug Types
    3. C
    4. Python
    5. Java
    6. Perl
    7. x86 Assembly Language
  15. Index

Product information

  • Title: Find the Bug A Book of Incorrect Programs
  • Author(s): Adam Barr
  • Release date: October 2004
  • Publisher(s): Addison-Wesley Professional
  • ISBN: 0321223918