Article P4F3 CodeSOD: A Handle on Events

CodeSOD: A Handle on Events

by
snoofle
from The Daily WTF on (#P4F3)

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 ; }}
inedo50.png[Advertisement] Use NuGet or npm? Check out ProGet, the easy-to-use package repository that lets you host and manage your own personal or enterprise-wide NuGet feeds and npm repositories. It's got an impressively-featured free edition, too! TheDailyWtf?d=yIl2AUoC8zANCtAOReknpQ
External Content
Source RSS or Atom Feed
Feed Location http://syndication.thedailywtf.com/TheDailyWtf
Feed Title The Daily WTF
Feed Link http://thedailywtf.com/
Reply 0 comments