Here is some pseudocode and paraphrased comments:
// Allow time for screen to start before content reset.
// Delay time determined by testing with platform version 5.
delayCall(0.01, contentReset())
Basically, the programmer figured out that on his specific test device after a dozen or so test runs that 1/100th of a second delay was just the right delay to accomplish what he wanted to have happen without causing any obvious problems for himself at the time.
Inevitably, this has led to occasional timing problems and instability.
Does this bad practice have a well known anti-pattern or code smell name?
What is the list of drawbacks for this practice?
6
This sort of thing is so blatantly fragile it probably doesn’t need a name; anti-patterns typically get names as part of the effort to teach people to recognize and avoid them. But I think temporal coupling might be what you’re looking for.
That term is normally used for things like “You must call init() before doStuff()”, but it seems reasonable to extend it to “You must wait 0.01s before calling doStuff()” as well.
1