CodeSOD: Universal Problems
Universally Unique Identifiers are a very practical solution to unique IDs. With 10^30 possible values, the odds of having a collision are, well, astronomical. They're fast enough to generate, random enough to be unique, and there are so many of them that- well, they may not be universally unique through all time, but they're certainly unique enough.
Right?
Krysk's predecessor isn't so confident.
key = uuid4()if(key in self.unloadQueue): # it probably couldn't possibly collide twice right? # right guys? :D key = uuid4()self.unloadQueue[key] = unloaded
The comments explain the code, but leave me with so many more questions. Did they actually have a collision in the past? Exactly how many entries are they putting in this unloadQueue? The plausible explanation is that the developer responsible was being overly cautious. But... were they?
Krysk writes: "Some code in our production server software. Comments like these are the stuff of nightmares for maintenance programmers."
I don't know about nightmares, but I might lose some sleep puzzling over this.
[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!