How To Write More Bugs

Some tricks and tips on how to create more bugs in your codebase.

Why Write More Bugs?

  • Debugging is super fun, especially when it’s someone else debugging your code!
  • Job security. More bugs, more work to do!
  • It’s a learning experience!

How To Write More Bugs

Write More Code

The simplest way to write more bugs is to write more code. The more code you write, the more opportunities there are for bugs to creep in.

💡 According to a totally scientific study I just made up, the number of bugs in a codebase is roughly proportional to the lines of code.

Some tips for writing more code:

  • Don’t use existing libraries, always write your own implementation!
  • Create wrapper functions around simple operations.
  • Split simple operations into multiple steps with intermediate variables.

Write Spicy Code

While writing more code is the simplest way, it’s not the only way. It’s also a lot of work!

Luckily, there is a more effective way to introduce more bugs with less work: write spicy code by introducing a ton of complexity and uncertainty!

Some tips for writing spicy code:

  • Use mutable state & global variables everywhere.
  • Write lots of nested loops and conditionals.
  • Rely on implicit type coercion as much as possible.
  • Use type assertions to lie to the compiler and silence those pesky type errors!
  • Don’t handle errors! Just throw them over the wall to the next guy.
  • Create elaborate “reusable” abstractions and keep adding special cases as you go.
  • Always rely on external databases and services. Those never go down!
  • Break your monoliths into tightly-coupled microservices.
  • Introduce circular dependencies between parts of your system.

Getting Your Bugs Deployed To Production

Many companies have annoying processes and “best practices” to catch bugs before they get into production, like code reviews and testing, but we can work around that.

How To Get Around Testing

Ideally you don’t want to write any tests, but if you must, here are some tips:

  • Keep your tests fun. Only test the happy paths!
  • Write flaky tests. You want tests that only fail sometimes. Over time, this will condition your teammates into subconciously ignoring them so you can ship more bugs!
  • Write tests that call your code but don’t make any assertions. This will fool the annoying code coverage threshold check!

How To Get Around Code Reviews

It’s fairly trivial to fool the automated code checks, but what about humans?

  • Make your pull requests as large as possible and packed with unrelated changes — people tend to skim
  • Don’t release often. Stack up as many commits as possible before releasing.
    • This makes bugs more fun to find, isolate and revert.
    • Combo bonus: Allows you to sneak in more bugs into a single release!
    • Environmental bonus: Most likely, someone else will release your code. Now they’re on the hook!

Conclusion

  • Write less code.
  • Keep your code simple! Complexity is the root of all evil.
  • Don’t forget to test unhappy paths and edge cases.
  • Try to keep your pull requests small and focused.
  • Release often to make it easier to find and revert bugs.

💡 Watch: Rich Hickey - Simple Made Easy