Code Smell 148 — ToDos

Code Smell 148 — ToDosWe buy debt for our future selves. It is payback timeTL;DR: Don’t leave TODOs in your code. Fix them!ProblemsTechnical DebtReadabilityLack of ConfidenceSolutionsFix your TODOsContextWe encounter TODOs in our code. We count them.We…


This content originally appeared on Level Up Coding - Medium and was authored by Maximiliano Contieri

Code Smell 148 — ToDos

We buy debt for our future selves. It is payback time

TL;DR: Don’t leave TODOs in your code. Fix them!

Problems

  • Technical Debt
  • Readability
  • Lack of Confidence

Solutions

  1. Fix your TODOs

Context

We encounter TODOs in our code. We count them.

We seldom address it.

We started owing the technical debt.

Then we pay the debt + the interest.

A few months after, we pay more interest than the original debt.

Sample Code

Wrong

public class Door
{
private Boolean isOpened;
    public Door(boolean isOpened)
{
this.isOpened = false;
}
    public void openDoor()
{
this.isOpened = true;
}
    public void closeDoor()
{
// TODO: Implement close door and cover it
}
}

Right

public class Door
{
    private Boolean isOpened;
    public Door(boolean isOpened)
{
this.isOpened = false;
}
    public void openDoor()
{
this.isOpened = true;
}
    public void closeDoor()
{
this.isOpened = false;
}
}

Detection

[X] Automatic

We can count TODOs.

Tags

  • Technical Debt

Conclusion

We can count TODOs.

Most linters do it.

We need the policy to reduce it.

If we are using TDD, we write the missing code right away.

In this context, TODOs are only valid when doing Depth First development to remember open paths to visit.

More Info

Credits

Photo by Eden Constantino on Unsplash

After you finish the first 90% of a project, you have to finish the other 90%.

Michael Abrash

Software Engineering Great Quotes

This article is part of the CodeSmell Series.

How to Find the Stinky parts of your Code


Code Smell 148 — ToDos was originally published in Level Up Coding on Medium, where people are continuing the conversation by highlighting and responding to this story.


This content originally appeared on Level Up Coding - Medium and was authored by Maximiliano Contieri


Print Share Comment Cite Upload Translate Updates
APA

Maximiliano Contieri | Sciencx (2022-07-13T01:42:03+00:00) Code Smell 148 — ToDos. Retrieved from https://www.scien.cx/2022/07/13/code-smell-148-todos/

MLA
" » Code Smell 148 — ToDos." Maximiliano Contieri | Sciencx - Wednesday July 13, 2022, https://www.scien.cx/2022/07/13/code-smell-148-todos/
HARVARD
Maximiliano Contieri | Sciencx Wednesday July 13, 2022 » Code Smell 148 — ToDos., viewed ,<https://www.scien.cx/2022/07/13/code-smell-148-todos/>
VANCOUVER
Maximiliano Contieri | Sciencx - » Code Smell 148 — ToDos. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/07/13/code-smell-148-todos/
CHICAGO
" » Code Smell 148 — ToDos." Maximiliano Contieri | Sciencx - Accessed . https://www.scien.cx/2022/07/13/code-smell-148-todos/
IEEE
" » Code Smell 148 — ToDos." Maximiliano Contieri | Sciencx [Online]. Available: https://www.scien.cx/2022/07/13/code-smell-148-todos/. [Accessed: ]
rf:citation
» Code Smell 148 — ToDos | Maximiliano Contieri | Sciencx | https://www.scien.cx/2022/07/13/code-smell-148-todos/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.