-1

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?

  • 2
    This question is about delay-based synchronization. Obviously inline parameter is not a main point here. I'd vote for reopen. – Basilevs Apr 16 '15 at 4:55
  • 1
    I have edited the title so that those mods who only skim titles will not think this is duplicate of "hardcoded values" question. – Jeff Apr 17 '15 at 15:03
  • 1
    I would rather not edit the content of the question itself to explain how it is different from the "hardcoded values" question because that is self-evident by any who read it fully. – Jeff Apr 17 '15 at 15:05
  • 2
    is your google broken? ;-) google.co.il/… – AK_ Apr 17 '15 at 15:51
  • 1
    This question has nothing to do with the question asking "Is it ever a good idea to hardcode values into our applications?". If your synchronization mechanism is "wait 500ms for the dongle to process its widget" (or whatever), it doesn't matter if you hard-coded the value "500ms", got it from a .config file, got it from the database, etc. The question of whether something's hard-coded is orthogonal to the question of whether a system exhibits proper synchronization. – user1172763 Apr 17 '15 at 17:50
1

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.

  • Searches on "temporal coupling" also lead to articles on "temporal cohesion". All great information. Thanks. – Jeff Apr 21 '15 at 18:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.