As developers, we try to write software that will be helpful to our users. Sometimes, we'll do key-by-key examination of what they're typing to do auto-complete. Sometimes, we'll look at a type-field entry to display the relevant subset of subordinate fields to be entered. Sometimes, we'll even try to coalesce error messages so that the user gets one message with a list of mistakes as opposed to one message per mistake.

Of course, it helps if the logic to detect multiple errors and coalesce them into one is correct.

Mike M. was supporting a system that had an event queue. In the case of this particular queue, the messages were all for the same condition. To be helpful, the cow-orker who wrote it decided to only display the pop-up for the first message in the queue and silently swallow the rest.

For the longest time, the system generated a single message for the given condition and so only a single pop-up was ever displayed.

Recently, something unrelated changed, and the system started generating a large number of identical events at once on the queue, which exposed a flaw in the coalescing logic; it took Mike four minutes of continuous clicking to get through the queue of event messages:

SomeClass::eventHandler(Event e) {
   if (!necessaryThing) {
      static bool showingError = false;
      if (showingError)
         return ;
      showingError = true;
      QMessageBox::warning(this, tr("App"), tr("Error message"));
      showingError = false;
      return ;
   }
}
[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!