These are the reasons software bugs happen

Petar Simic
Author
11 minutes
Reading time
Development
Category

Every development team wages an infinite war with software bugs.

Now, while bugs are a natural part of coding, being overrun by them could indicate a serious organizational or technical problem at your workplace.

In this article, we’ll examine some of the most common reasons why software bugs happen and suggest possible solutions for each one.

We’ll start by discussing one of the most prevalent ones: poor communication among team members.

Poor communication during development

Highly complex projects depend on strong collaboration between multiple stakeholders. 

Successful project completion can be seriously jeopardized if those participants can’t communicate effectively and without misunderstandings.

Poor communication presents a bigger issue than you might think. In fact, research shows that almost a third of projects fail because of it.

Source: Shake

The software development industry is especially vulnerable in this regard because developers working on the same software products need to be in perfect sync and communicate seamlessly to produce functional code.

An interesting case where this link between quality code and good communication became particularly visible happened in 2007 with the unsuccessful launch of Windows Vista.

Source: Wikipedia

The operating system was so riddled with bugs and errors that it’s still regarded as Microsoft’s messiest OS launch.

Microsoft’s research team busied itself with finding the main culprit for the failed launch and what they discovered was quite surprising.

As it turns out, the reason why Vista’s code was so buggy wasn’t technical. It was organizational. 

Some of the problems stemmed from too many people being involved with the code to keep track of, a large turnover of programmers who worked on the code at different stages, breaks in communication between developers and decision-makers, and so on.

Bug and crash reporting tool for your mobile app.

In fact, the post-mortem analysis was so on-point that it led to a new model of predicting bugs in code, one that focused on the organizational structure of the company more than on the code itself. 

Incredibly, this new model soon proved to be a superb predictor of bugs in code. 

Developers use it to estimate if the code will have problems in the future just by looking at the size and organization of the team working on it.

Source: August

As you can see in the table above, the number of developers and the quality of communication between them and decision-makers (aspects of organizational structure) can predict with almost 90% certainty that bugs will appear in the various modules of the code.

That’s a much higher score than any other prediction model we currently have.

The lesson learned by Microsoft goes to show how important communication and collaboration are to the success of a development project. 

Smaller, tightly-knit teams and open lines of communication with clients, decision-makers, and managers definitely do matter if you want to keep bugs in check.

Changes to project requirements

For software developers, rework, changes, and unplanned work still represent the biggest challenge when delivering a software project.

The statistics on this are quite clear.

Source: Statista

In their line of work, this challenge commonly arrives in the form of changing project requirements.

Just like in the previous section, poor communication is a big factor here. 

Clients often don’t know the consequences of changing their minds about the requirements they have for projects, and managers can sometimes exacerbate the problem by asking for modifications that developers will have a tough time carrying out.

Source: Reddit

There’s practically no winner here because projects get delayed, developers need to put in extra hours, and the quality of the code is seriously affected.

Unfortunately, there’s not much that can be done here, and changes in requirements will probably always be a part of software development reality.

However, what you can do is build code that’s resilient to change by following good development practices, such as: 

  • Keeping functions and methods small.
  • Using classes that refer to one thing and one thing only.
  • Favoring strong encapsulation classes to protect the code from outside interference.
  • Using inversion of control patterns for easier testing and maintenance.

By following these practices, changes will be much easier to implement and less likely to cause bugs and errors during development.

Also, remember the Agile principles and their insistence on delivering the project in small increments to facilitate changes and prevent too much work from going to waste.

As we said, changes in requirements are unlikely to be eliminated during the project, but there are ways to minimize the potential damage they can cause. 

Deliver working software frequently, from a couple of weeks to a couple of months, with a preference to the shorter timescale.

Focus on creating resilient code and deliver the software in batches, with quick feedback from decision-makers.

Bad coding practices

On the most basic level, coding is simply a way to translate ideas into a language that machines will understand and enable the developer to create software. 

Bad coding practices are those that complicate this exchange and obscure the original idea of the coder by overcomplicating the code and making it difficult to understand.

This kind of code is often called spaghetti code because the lines of logic and mental back-and-forth start to resemble spaghetti on a plate. 

Here’s an example to paint a clearer picture: 

Code like this is difficult to follow and stops making sense very quickly. 

Plus, it usually has redundancies and unnecessary elements that make it that much harder to trace an idea from beginning to end.

Overcomplicated, messy code makes bugs much more likely to appear, but the bigger problem might be finding and eliminating them because they blend in and don’t stick out like they would in structured code.

In these circumstances, buggy code is sometimes shipped with the product, which can have catastrophic consequences. 

For example, in 2013, Toyota was found guilty of “reckless disregard” after an accident caused by “unintended acceleration” in one of their vehicles resulted in death and serious injury for two passengers.

The investigation proved that the accident happened because of a software bug in Toyota’s driving system’s source code, which expert witnesses in the trial called “spaghetti-like.”

Source: CNN

To prevent your code from becoming a mess where bugs can remain undetected, just try to keep things as simple as possible.

Stick to one set of naming conventions to avoid duplicate or erroneous names for classes and avoid too much abstraction so that you’re always certain of what each line of code is referring to.

Also, see if you can use a lighter framework that can reduce the number of lines of code you need to create for certain functions.

For example, if you use the Bottle framework, you can work on web apps using a codebase that fits in one file.

Source: Bottle

In conclusion, bad coding practices can and do result in bugs. In the worst-case scenario, these bugs are impossible to spot and eliminate because of unintelligible code, which can result in faulty software being shipped.

Keeping abstractions and redundancies at a minimum and writing the simplest possible code should help you avoid this.

Poorly documented code

Developers are notorious for disliking writing documentation. 

For many, it simply involves a separate set of skills they don’t think they possess, while others see it as a waste of time in a work environment where time is always in short supply.

Andrés Reales, a senior full-stack developer, sums up the problem well on his blog:

Programmers hate writing documentation because documenting code keeps them from coding. Writing documentation is often seen as a secondary task, which programmers do when they’re not coding anything new. Programmers are good at coding but not as good at turning their ideas into writing. 

Nevertheless, documentation is essential to the success of a project because it explains what every line of code does and provides additional information that’s relevant to the code and product.

Source: Stepsize

Most importantly, documenting code allows developers to cooperate on a project without being in direct contact with each other. 

When documentation is ambiguous, unclear, or, worst of all, non-existent, developers who inherit the code or have to manage it are at risk of misunderstanding what parts of the code do. 

In those cases, it can be quite difficult for the new developer to do their job writing or managing the code without making any mistakes.

That’s exactly the situation this young developer from Reddit had to face in their new job:

Source: Reddit

The solution here is obvious: document your code.

Leave comments within the code whenever you feel like a segment of it isn’t self-explanatory or clear enough for a fellow developer (or even if it’s something that you, as the author of the code, might be in danger of forgetting after some time has passed). 

You can also enlist the help of Archbee, Nuclino, or some other documentation tool to create more comprehensive documentation you can share with the entire team.

Source: STORJ Docs

While writing documentation, use clear, unambiguous language because even the simplest misunderstanding can lead to inadvertent bugs.

For example, avoid using the phrase and/or and explain both cases individually.

If there’s cause for providing a link to an external resource, don’t hesitate to include it in your comments. 

Having additional information can only help the developer working on the code in the future.

For instance, there was no reason why the following comment couldn’t hold a link to the original source for the formula:

Source: The Overflow

Documentation exists to eliminate doubts and ambiguities from your code. 

Use it to make working with your code easier and you’re sure to prevent a great number of bugs from ever appearing.

Compromises made to save time

In the last section, we mentioned that time is of the essence in a software development environment. 

Let’s take a closer look at this problem because a lack of time can be another source of bugs in your code.

In software development, teams often face tight deadlines and understaffing, which inevitably leads to crunch times and overworked, burned out developers who start making mistakes because their focus starts to slip. 

Unfortunately, the perception that’s still held by many companies today is that spending more time programming will simply result in more code. 

The quality of the code written this way is seldom brought into question.

Experienced developers, like James Golick, are all too familiar with this issue:

The obvious problem with management’s formula is that a tired programmer can do more harm than good. A particularly nasty bug, for instance, can cost a team orders of magnitude longer to fix than it took to write. 

Another problem comes from poor project planning, which sometimes leads to cutting corners and sacrificing code reviews and testing so that the code is shipped on time, even if it’s full of bugs that could have been handled easily.

Developers are no strangers to this bad practice as well:

Source: Reddit 

While it’s true that testing and reviews take a lot of time, that’s really no reason to skip them entirely and good leadership on a coding project should always make time to review the code and eliminate as many bugs as possible.

Plus, the testing process can be partially automated using bug testing tools, such as Shake, which can log and report bugs in mobile apps in mere seconds. 

Its data-rich reports contain over seventy pieces of information, meaning testers can quickly understand the nature and source of the bug, as well as find a good way to eliminate it.

Source: Shake

Management is responsible for proper project planning and estimation. 

If you’re noticing there’s simply no time to ensure quality work and proper testing before code is shipped, it might be a good idea to start advocating for changes in the way projects are managed. 

More time will definitely result in fewer bugs as well as protect the sanity of the development team.

Conclusion

From problems arising from poor communication and the way projects are managed, to the practices that are used to write and maintain code, there are multiple reasons why bugs might be appearing in the code your team is working on. 

Fortunately, all of these causes have tried and true solutions and we discussed some of the most effective ones in this article.

That being said, there’s no dependable way to completely eliminate bugs and they will sometimes appear after the software is shipped. 

In those cases, it’s a good idea to work with a strong bug reporting tool that will help you stay informed and act quickly once a bug is discovered.

Shake offers a lightweight bug reporting tool for mobile apps that’s easy to learn and use, and won’t break the bank. Try it for free today and keep software bugs under control.

About Shake

Shake is a bug and crash reporting tool for mobile apps. It was founded in 2019 with the mission to help app developers spend less time on debugging and manual overhead — and growing daily since thanks to a small and dedicated team of geeks based in the EU.

Meet your favorite bug and crash reporting tool.

Add to app in minutes

Doesn’t affect app speed

GDPR & CCPA compliant