# Code Smell 179 - Known Bugs

> TL;DR: Don't track bugs. Fix them.

# Problems

- Hard to-track lists

- Technical Debt

- Functional Debt

# Solutions

0. Stop calling it a [Bug](https://maximilianocontieri.com/stop-calling-them-bugs)

1. Reproduce the [Defect](https://maximilianocontieri.com/stop-calling-them-bugs).

2. Cover the scenario with automation

3. Make the most straightforward fix (even hardcoding solutions)

4. Refactor

Welcome to TDD!

# Context

We don't like to be interrupted. 

Then, we create lists and delay fixes and solutions.

We should be able to change software easily.

We need to improve our software if we can't do quick fixes and corrections. 

Not by creating To-Fix lists.

# Sample Code

## Wrong

[Gist Url]: # (https://gist.github.com/mcsee/352ade4d98a059ed49e4312ae3bab44e)
```php
<?

function divide($numerator, $denominator) {
  return $numerator / $denominator;  
  // FIXME denominator value might be 0
  // TODO Rename function
}
```

## Right

[Gist Url]: # (https://gist.github.com/mcsee/d1323654df40648970e8058c0cbd55cc)
```php
<?

function integerDivide($numerator, $denominator) {
  if (denominator == 0) {
    throw new DivideByZero();
  }
  return $numerator / $denominator;  
}

// we pay our debts
```

# Detection

[X] Automatic 

We need to avoid creating bugs and issues.

# Tags

- Technical Debt

# Conclusion

We need to discourage bugs and issue trackers on the engineering side.

Of course, customers need to track their findings and we need to address them ASAP.

# Relations

%[https://maximilianocontieri.com/code-smell-148-todos]

# More Info

[Famous Bugs](https://en.wikipedia.org/wiki/List_of_software_bugs)

%[https://maximilianocontieri.com/stop-calling-them-bugs]

# Disclaimer

Code Smells are just my [opinion](https://maximilianocontieri.com/i-wrote-more-than-90-articles-on-2021-here-is-what-i-learned).

# Credits

Photo by [Justin Lauria](https://unsplash.com/@justinlauria) on [Unsplash](https://unsplash.com/s/photos/bug)
  
* * *

> In general, the longer you wait before fixing a bug, the costlier (in time and money) it is to fix.

_Joel Spolsky_

%[https://maximilianocontieri.com/software-engineering-great-quotes]

* * *

This article is part of the CodeSmell Series.

%[https://maximilianocontieri.com/how-to-find-the-stinky-parts-of-your-code]
