Part of being an app developer is fixing bugs. That’s OK, all great developers create bugs.
BUT fixing bugs can take so much time that you feel you can never work on new features. There must be a better way, right?
Of course, we need to write testable code and actually write easy to maintain tests. I encourage you to read up about functionality tests (if you use Flutter, Unleash the full power of Flutter widget tests is a good start).
But, on the day you have to fix a bug, how can you do it efficiently and effectively?
In a nutshell, you would:
- Investigate the bug
- Ask someone else to reproduce if you can’t
- Fix trivial bugs straight away
- Use the creative power of your brain to help you generate ideas to fix non trivial bugs
- Reflect after difficult bugs
10 minutes to investigate
To fix a bug, you need to be able to reproduce it (no kidding, Sherlock!).
Get all the details you can from whoever is reporting the bug. Then give yourself 10 minutes to reproduce it.
If you can’t reproduce it, ask for more details and give yourself 10 more minutes.
If you still fail to reproduce it again, ask another team member to reproduce it (they don’t need to be a developer).
Why ask someone else? We all use software in specific ways, without noticing. We scroll differently, we have different devices, we type differently etc
If you can reproduce the bug and it is trivial to fix, it’s your lucky day, go ahead and fix it.
5 steps to handle non trivial bugs
Most likely, the bug will not be trivial. I wouldn’t write this if we only encountered trivial bugs.
Over the years, I’ve found an effective method to handle those pesky bugs, as you can easily waste a full day on them (I have done that many times).
Step 1: Explain the bug in writing
Somewhere in the code where the bug manifests itself, write a TODO comment explaining the bug: what are the conditions, what happens, what should happen, examples of bug data.
In addition to examples of bug data, write down examples of bug data for the happy path. I know it may seem silly to do that, but your brain can pick up patterns when reading, so you never know, the answer may “jump at you”.
Step 2: Ask why
Re-read your TODO comment and ask yourself “Why” for each condition for the bug, and for each example of bug data. E.g. “Why do we have users with null middle names, and other users with empty string middle names?”.
Then ask “Why” again. And again. Find the information each time.
Yes, this may involve asking a colleague or your team leader. It can feel scary if you’re a junior developer, but strong teams are those who solve bugs together, not in silos.
Sometimes, bugs in one system (e.g. app) are the result of a bug in another system (e.g. backend legacy system), so it’s worth figuring out if the fix really should be in your system.
Step 3: Let your subconscious brain do some work.
Take a break from the bug.
Even better, take a break from focused work and move to scatter focus. Scatter focus is when your mind wanders.
Generally speaking, any activity that is boring and doesn’t need much of your attention will allow your brain to go into scatter focus.
That could be upgrading your IDE, attending a company wide meeting, waiting for the kettle to boil. Any activity where you want to reach for your phone out of boredom is a good candidate for getting into scatter focus mode. Don’t reach for your phone, don’t check your Twitter feed, allow your mind to be bored.
When you go back to the bug, you might have some ideas to try. If you do, try them. If not, let’s try step 4.
Step 4: Explain the bug to someone orally
Grab a colleague and explain the bug to them.
As we’re trying to maximise your brain’s innate ability to solve problems, this step should be as different from step 1 as possible, so explain the bug orally (in person or video call).
If you’re a solo developer, talk to yourself out loud. I know, I know, I sound crazy, but it works. Or explain it to a willing partner/child/friend (I have fixed many bugs trying to describe them to my daughter).
If you still can’t come up with ideas for fixing the bug, let’s move to step 5.
Step 5: Review checklist of prompts
In this last step, you will use prompts, and quick actions, to come up with ideas to fix your bug.
- Is there a large function or class involved in the feature around the bug? –> Break it up.
- Could there be a race condition between events? –> Make a list of all events involved (e.g. UI events, API calls, db calls etc). Then, add a significant artificial delay to one event at a time, and try to reproduce the bug.
- Is there a function with complex logic and no tests? –> Write unit tests for it.
- Is your code using wrong default values? –> Check all constructors involved in your functionality, to ensure they’re not injecting some values that are messing up your data.
Most bugs have been fixed by now. But, if you face a bug you still can’t fix, it’s time to hand it over to a colleague. If you’re a solo developer, you can hand it over to yourself in 3 months.
After the fix
If the fix was tricky, ask yourself the following questions:
- Could you have caught the bug with a functionality test before releasing the code? –> Invest time in writing functionality tests.
- Was the bug due to a misunderstanding in the code? –> Improve documentation.
- Was the bug due to a misunderstanding of an internal dependency? –> Ask their team leader to improve their documentation.
- Was the bug due to a misunderstanding of an external open source dependency? –> Create a PR to improve their documentation.
- Was the bug due to a misunderstanding of an external closed source dependency? –> Contact them if you think it’s a common misunderstanding.
- Was the bug a special use case no one had mentioned before? –> Let the product owner know about it.
- Was the bug due to spaghetti hellish code? –> Invest time in writing functionality tests, so you can refactor that code in a few months.
Summary
- Investigate the bug
- Ask someone else to reproduce if you can’t
- Fix trivial bugs straight away
- Use the creative power of your brain to help you generate ideas to fix non trivial bugs
- Reflect after difficult bugs
If you found this article useful, why not try Chunkod?
With Chunkod, you will:
Learn the skills you need to become a fully resilient developer, no matter the framework and programming language you currently use.
Leverage small chunks of time, so you can progress in your career without sacrificing your hobbies or family/friend time.

Mobile app developer with 14 years experience. Started with the Android SDK in 2010 and switched to Flutter in 2017. Past apps range from start ups to large tech (Google) and non tech (British Airways) companies, in various sectors (transport, commercial operations, e-commerce).