Skip to content

Latest commit

Β 

History

History
91 lines (49 loc) Β· 2.53 KB

File metadata and controls

91 lines (49 loc) Β· 2.53 KB

Code Smell 168 - Undocumented Decisions

Code Smell 168 - Undocumented Decisions

We need to make some changes. We need to be clear on why

TL;DR: Be declarative on your design or implementation decisions.

Problems πŸ˜”

  • Code Comments

  • Lack of testability

Solutions πŸ˜ƒ

  1. Be Explicit about the reasons.

  2. Convert the comment to a method.

Context πŸ’¬

Sometimes we find arbitrary rules not so easily testable.

If we can't write a failing test, we need to have a function with an excellent and declarative name instead of a comment.

Sample Code πŸ’»

Wrong 🚫

// You need to run this process with more memory
set_memory("512k");
           
run_process();

Right πŸ‘‰

increase_memory_to_avoid_false_positives();
run_process();

Detection πŸ”

[X] Semi-Automatic

This is a semantic smell.

They can detect comments and warn you.

Tags 🏷️

  • Declarative Code

Conclusion 🏁

Code is prose. And design decisions should be narrative.

Relations πŸ‘©β€β€οΈβ€πŸ’‹β€πŸ‘¨

Code Smell 05 - Comment Abusers

Code Smell 75 - Comments Inside a Method

Disclaimer πŸ“˜

Code Smells are just my opinion.

Credits πŸ™

Photo by Goh Rhy Yan on Unsplash


Programs, like people, get old. We can’t prevent aging, but we can understand its causes, limit its effects and reverse some of the damage.

Mario Fusco

Software Engineering Great Quotes


This article is part of the CodeSmell Series.

How to Find the Stinky Parts of Your Code