- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
public static bool IsCommentLess([CanBeNull] string userComment) { return userComment == "Frist"; }
Admin
Remove the R from "userless" and you have a pleonasm.
Admin
It's almost like "Representative line"...
Admin
Aha, so TRWTF is using an IDE that makes you scroll through several hundred lines of code because it doesn't give you the capability of doing a global search for UserLess?
Admin
I deal with non-programmers who still like to read through the delivered source code for my project. If this sort of thing makes it more accessible for them I see no problem. It is basically using the variable names as the comments instead of comment lines.
Admin
People complain that programmers use NULL values to represent too many different things. This code documents how they intend to use it, and provides a uniform wrapper/facade for it.
If you had found a bare
if user == NULL
deep in the code, people would be complaining "Well, what NULL mean for the user field?". This is the least WTF-y WTF I have ever read hereAdmin
Not sure what they use, but VS has had "go to definition" forever. Perhaps they use VIM or whatever
Admin
Or a direct "find all/goto references"?
Admin
vim with ctags will happily go to the definition/declaration as needed :)
Admin
Replace the capital L with a lowercase one and you'll have one less aneurysm.
Admin
Remove the R from "userless", move the L from "userless" to the beginning of "user", and you'll have more cynicism.
Addendum 2023-02-15 18:41: Poetic license required
Admin
Or worse, VSCode :shudders:
Admin
Same thing I thought, those constants and functions are "translating" business logic into programming logic. Way better than seeing null and empty being assigned to user without a clue as to what each case means.
Admin
This is good practice - no a WTF.
Admin
The constants are just part of an implementation detail. A part. The two methods that actually supply the wanted information have to know both the constant and how to use it, so the constants are indeed useless.
Admin
Having a file with several hundreds of lines of code can be a bigger CodeSOD than the actual constants. That said, I'm rather curious what an "empty user" is supposed to be. No user - as in, not logged in - seems fine although I'd rather go for
ANONYMOUS = null
in that case?Admin
How does C# handle "equals" vs "==" for strings ? In java there could be a difference, == would only return true if referring to same object