Code Smell 186 - Hardcoded Business Conditions
You are FTX and your code allows special cases

I’m a senior software engineer loving clean code, and declarative designs. S.O.L.I.D. and agile methodologies fan.
Search for a command to run...
You are FTX and your code allows special cases

I’m a senior software engineer loving clean code, and declarative designs. S.O.L.I.D. and agile methodologies fan.
No comments yet. Be the first to comment.
In this series, we will see several symptoms and situations that make us doubt the quality of our developments. We will present possible solutions. Most are just clues. They are no hard rules.
The perfect prompt doesn't instruct the model on what it already knows how to do.

Approve the logic once, then let it run the same way forever.

Different stages need different brains.

One Second Brain doesn't scale past one skull.

Style errors double when nobody enforces them.

TL;DR: Don't add hard business rules to your code.
Open / Closed Principle Violation
Hardcoding
Testability
Reify the condition.
Create configuration options and set the exception on the configuration behavior.
Don't use Settings/Configs.
According to Reuters, in a recent FTX scandal, there was a hardcoded condition to skip risk controls to its own portfolio.
The code was explicit and developers were aware of that rule.
if (currentExposure > 0.15 && customer != "Alameda") {
// Be extra careful not to liquidate
liquidatePosition();
}
customer.liquidatePositionIfNecessary(0.15);
// This follows the Tell, Don't ask principle
[X] Semi-Automatic
We can search for primary hardcoded conditions (related to primitive types).
We might have more false positives than actual problems.
If you make code reviews, pay special attention to this kind of hard coding.
Code Smells are just my opinion.
Photo by Alexander Mils on Unsplash
Computer science inverts the normal. In normal science, you're given a world, and your job is to find out the rules. In computer science, you give the computer the rules, and it creates the world.
Alan Kay
This article is part of the CodeSmell Series.