The Skill of Finding Bugs and Their Root Cause in Software Development

Ever wondered how you can meet deadlines and impress your team, QA, and manager with the skill of quickly pinpointing the root causes and identifying the changes required to fix the issue?. I will share some useful tips and my own experience with you.

I have more than 6 years of experience in mobile application development, and I consider mobile applications to be harder to develop than websites due to variations in hardware, especially in Android because it is open source. Although modern smartphones are rich in resources, there are still limitations. Having worked on almost every type of mobile application, such as image processing, integrating native C++ code (Android NDK), API integration, Bluetooth integration, using sensors, integrating maps, etc., I was lucky enough to experience and fix a variety of bugs in different projects, such as out-of-memory errors, garbage collection errors, default keyboard not working, etc. Most of the time, I had to start work on a project that was already developed and had some critical bugs waiting to be fixed or needed new features to be added. Let's go through the journey and take a look at some of the critical bugs that I was able to fix within the deadline, and even straight away.

Tips for quickly getting used to a project:

Some people might like to read the whole code first before working on a project, but it can be a very time-consuming process. So, how can you save time at the start of a project and impress others with the speed of your adoption of new code?

Whenever I am assigned to work on a new project or codebase, I start by reading the documentation if available, building the project, and running it to understand the core features or functionalities offered by the software. Then I straight away pick up the easy bugs to fix. It can be as simple as just changing the button text and raising a Pull Request to fix that without wasting any time. I did the same in two of my last jobs and received immediate feedback from teammates: 'You are so quick to raise your first PR.' I continued that speed and ended up with more than 10 Pull Requests in the first 2 weeks, which was enough to impress the managers. So, starting with easy tasks is crucial for understanding the codebase of a new project. The other tip for getting used to quickly is to try to relate your current challenge or task with the work you have done in the past. Try to think if you have already fixed the issue in the past, which is related to your current task, or if you can fix your current bug just by making some changes to the solution you have used for some other issue.

Try to think outside the box, Be creative:

Software engineering is all about being creative and finding quick and easy solutions to problems. Don't limit yourself, because a problem can be solved in multiple ways, but you have to find the most optimal way. For example, if there is a task to print a specific series of numbers assigned to 5 programmers with equal abilities, each programmer will come up with a unique solution, but the output will be the same. The most optimal solution in that case will seek the attention.

Once, I was assigned a task related to an Android application with a deadline fast approaching. It had an issue in a WebView where the text field was not accepting input from the current keyboard at all. I was a junior at the time, and my senior team member, with 5 years more experience than me, had been working on that project and was stuck on this bug for the last 7 days. Then, I ended up fixing that bug in just half an hour. I tried to be creative; I had overridden a method in the Keyboard Input type class of the Android SDK and forced the WebView to use the default keyboard for all fields to fix that issue. So, thinking outside the box is important because sometimes as programmers, we limit ourselves to specific patterns of code structure and think too much about the rules.

Finding the root cause. Skill of debugging:

You must have strong debugging skills to find the root cause of the issue. Sometimes, you try to fix the bug in your code and spend hours or days doing so, but in the end, you find that the error is caused by some external library or SDK itself due to an update or a bug in an open-source library. Use different debugging techniques such as breakpoints, logs, memory profilers and exception traces to find the root cause.

Sometimes, you will not get accurate exceptions for the error. For example, if you are working with the Android Native Development Kit, using C++ code in your Android Java/Kotlin application, and your app crashes, there is a chance that you will find some unrelated error logs after the crash, which could be an out-of-memory error or an error related to garbage collection. It may not point you towards a specific line in Java/Kotlin code. In this case, you have to use other tools such as a memory profiler (in Android, it is Android Profiler) to check memory usage. Then, you can perform garbage collection manually, as the Android OS can take some time to clear memory even if the native C++ object is released and not needed anymore.

Finding the root cause. Skill of using Google:

I would consider searching for a related solution on a search engine to be a crucial skill. You must know how to use words to get the information or code snippet you need to fix your problem. It's like prompt engineering and asking ChatGPT to provide you with the relevant information. If you don't know how to extract the required information from a search engine, you will waste more time, and it can also shift your focus to non-optimal solutions. Sometimes, you may need to copy the exception message and paste it into Google straight away to get answers related to the problem, and sometimes you may need to use relevant words to search for a solution effectively.

Finding the root cause: The skill of debugging third-party libraries:

Debugging third-party libraries is important because it may be possible that a core feature in your project relies on a third-party library. Whenever you encounter a crash or a line of code with a bug, ask yourself a question: Is this line of code using a method from any third-party library? If that is the case, you know that the bug is potentially caused by that library, and it's not your fault if you're using that library according to recommendations.

For example, If you are a cross-platform mobile developer, then you should have command over native Kotlin/Java/Swift/Objective-C code as well to debug third-party modules and libraries. I was working on a React Native project, and the task was to update the React Native version from 0.69.4 to 0.71.12. The project used the react-native-reanimated library version 2.5.x, and after the update, I had to switch to a compatible version of Reanimated, which was 3.5.x. I updated my code to match the recommendations of the 3.5.x version.

However, this update actually messed up the animations in the app because there was a bug in the Reanimated update. So, I had to debug the app by downgrading the Reanimated version first and then checking with the latest version to ensure that the bug was caused by the library. I ended up reporting the bug to the Reanimated GitHub repo and earned a contribution to the open-source project. Another advantage of debugging library skills is that you can contribute to their GitHub repos and earn extra points in job interviews. You can see my contribution here

Conclusion:

In conclusion, mastering the skill of quickly adapting to code written by others is indispensable in the realm of software development. Not only does it facilitate smoother collaboration within teams, but it also fosters a culture of efficiency and innovation. By equipping oneself with proficient debugging techniques, effective problem-solving strategies, and a willingness to explore unconventional solutions, developers can not only navigate through complex codebases but also contribute significantly to the success of their projects. Remember, in the dynamic landscape of programming, the ability to think critically, adapt swiftly, and collaborate effectively is the key to unlocking new opportunities and achieving greater heights in one's career.

That's it from me for now. I hope this article helps you in your career. Please like, comment, and share :)

1
Subscribe to my newsletter

Read articles from Muhammad Hassaan directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Muhammad Hassaan
Muhammad Hassaan

Results-driven and highly skilled software engineer with over 5 years of experience in mobile applications development, specializing in React Native, Android Native, Flutter, and iOS Native. Proficient in a variety of programming languages including Kotlin, TypeScript, JavaScript, React, Java, PHP, and Python. Holds an MSC in Applied Artificial Intelligence and Data Analytics from the University of Bradford, UK, demonstrating a strong foundation in data science. Currently contributing as a Mobile Applications Developer at Prevayl in Manchester, UK for the past 2 years, with a proven track record of delivering high-quality software solutions. Possesses a versatile skill set encompassing web development using React and NodeJs. Equipped with the expertise to transition into a role as a Data Scientist, leveraging the academic background and practical experience to analyze and derive insights from data. Known for adaptability, problem-solving prowess, and a commitment to staying abreast of emerging technologies. Adept at collaborating with cross-functional teams to drive successful project outcomes. Passionate about pushing the boundaries of technology to create innovative and impactful solutions. Can show around 300 Github Pull Requests to showcase practical work