Timestamps are widely used. They have a central issuing authority and do not go back, do they?
TL;DR: Don't use timestamps for sequence. Centralize and lock your issuer.
Bad Accidental Implementation (Timestamp) for an Essential Problem (Sequencing).
Use a centralizing sequential stamper. (NO, not a Singleton).
If you need to model a sequence, model a sequence.
# using time module import time # ts stores the time in seconds ts1 = time.time() ts2 = time.time() #might be the same!!
numbers = range(1, 100000) #create a sequence of numbers and use them with a hotspot #or sequence = nextNumber()
Timestamps are very popular on many languages and are ubiquitous.
We need to use them just to model... timestamps.
This smell was inspired by recent Ingenuity software fault.
If we don't follow our MAPPER rules and model sequences with time, we will face trouble.
Luckily, Ingenuity is a sophisticated Autonomous vehicle and has a robust fail-safe landing software.
This video describes the glitch
Code Smell 39 - new Date()
Maxi Contieri ⭐⭐⭐ ・ Dec 1 '20 ・ 1 min read
Code Smell 32 - Singletons
Maxi Contieri ⭐⭐⭐ ・ Nov 23 '20 ・ 2 min read
The most beautiful code, the most beautiful functions, and the most beautiful programs are sometimes not there at all.
Software Engineering Great Quotes
Maxi Contieri ⭐⭐⭐ ・ Dec 28 '20 ・ 13 min read
This article is part of the CodeSmell Series.
Top comments (0)