Doreann has touched this particular function many, many times. In all those times, she never noticed this particular little line, dropped in by a third-party contractor that has long since cashed their check and wandered off to other things.
(user?.betaMode || !user?.betaMode) && (specialRuleCode())
My suspicion is at some point, the specialRuleCode was only supposed to run if the user was signed up for beta features. At some point, it left beta and was supposed to run for all users. I imagine the requirement was "it should also run if the user is not in the beta," and thus it was implemented exactly that way.
Of course, the real WTF isn't the tautological condition: it's (ab)using logical operators to control whether a branch runs. That, I imagine, made some developer feel like they were being clever. "user?.betaMode && specialRuleCode is so much more concise than an if statement!" they said to themselves while typing this.
Honestly, that kind of "clever" is not something I'd expect from a third party contractor. It makes me think the original line started in-house by a "clever" developer, and the third party added the || portion in just the dumbest way to implement the requirement given to them.
Either way, Doreann is ashamed that it's lingered this long in the code base, writing:
dishonor for it being there
dishonor for me not recognizing this
dishonor on my whole family
I'm just glad that we're finally breaking through and getting readership in the Klingon developer community.
Your journey to .NET 9 is more than just one decision.Avoid migration migraines with the advice in this free guide. Download Free Guide Now!
This post originally appeared on The Daily WTF.

