- 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
Er, no. It's considered a Good Thing to write code that is easy to read.
Excessive verbosity and superfluous sesquipedalianism are not, even in exceptional circumstances, admirable contributions to the legibility of ones programmatic endeavours, and one should be abstemious in the employment of such.
Admin
I think the WTF is that this is the second system we know about that the "Java Wizzard" has had to abandon, and who knows how many more. You can get away with poor architecture until the code gets to a certian size (in my experience 7-10K LOC in C family languages.) At that point bad code gets to brittle to work with.
Our java wizzard seems to be doing the initial parts and getting the (easy) first gee-whiz on a lot of projects without ever driving one to completion. When the code gets to messy and needs real architecture he "retires" to another new project.
Admin
The fun is that I got this post much better than those with a lot of small words that try to keep it simple.
Admin
um .... WTF!? ... can you dumb that down for me please?
Admin
Admin
Are you broadcast on Channel 39?
Admin
The comments are the code. Why increase my work tenfold if I can just make it easy to understand by more descriptive naming patterns? I want to read code, not a novel commenting the code!
I bet you do. I long for the day when you realize there is a need for more than 640k, but I'll not hold my breath. Code with arbitrarily small names and more difficult to read, and usually written by those who consistently fail to comment it properly. I'd take the descriptive names with no comments over your useless (and never really consistent) shorthand notation with minimal effort to comment.
Um, I thought you didn't want to: read(a_novel_of_code_due_to_overlong_names).
Um, if that's in reference to identifier constructs like ${this is a variable}, then I'd have to agree that I don't like the spaces either, but it's not that much different than the overabundant use of the underscore (which in my mind looks like you are trying to underline something).
Admin
You kinda failed in doing what you wanted to accomplish. It appears that you are trying to use overly descriptive words to make an example of how the Java Wizard's code was too descriptive. I have NO idea what you said thanks to your thesaurizing. On the other hand, the Java Wizard, while using long and descriptive variable names, doesn't use words that no one understands. Thus he is left with variables that have names of what they are (A REALLY GOOD THING). Is it the best naming convention in the world? NO. Is it the worst or even WTF worthy? Definitely not the worst, and only slightly WTF worthy. It is very easy to tell that the variable hasPermissionsRequiredToCompleteSigningStep stores a true/false value that represents whether the user has the proper permissions to complete the signing step. Sure, it would have been better if the variable was canCompleteSigningStep, but to flame the guy at such lengths for being a little more verbose than that is hardly called for.
Is the biggest WTF of this short circuiting the boolean? I would hardly think so. A WTF of course, but a big one, hardly. Frankly I think he did it the way he did so that it would be more readable. It simply breaks down the logic into simpler bytes for easier consumption. I'm 99.9% positive that this programmer knew that the whole thing could have been replaced with:
boolean hasPermissionsRequiredForRenegotiationAction =
currentInteractiveUser.HasSpecificPermission
(SpecificApplicationPermissions.CompleteClosingStep) &&
currentInteractiveUser.HasSpecificPermission
(SpecificApplicationPermissions.InitailizeClosingStep) &&
currentInteractiveUser.HasSpecificPermission
(SpecificApplicationPermissions.CompleteApprovalStep);
Admin
Admin
Christ, you sound like my mother. I already don't respect you.
Admin
Ok. Drop the thesaurus and nobody gets hurt. Just step away. Slooowwly... Slooowwwly. There ya go.
By the way the google toolbar spellcheck doesn't know what "sesquipedalianism" is. :)
Admin
Big words make programs hard to understand. Don't use them.
Admin
Have you ever had to use a language that consistently spells wrongly? It's COLOUR! The red-ness of the high tech beanbag is its COLOUR.
Their, I feal better now.
Admin
Maybe it's just me, but I'll take long (even overly long) variable names over short ones any day. I'd have IsUserValidatedAgainstSomeSystem over the half-assed, AOLICQJABBERAIM generation text-speak of IsUsrValSys.
Besides, in the age of large screens, high resolution and Visual Assist-esque code-completion, I can't see any decent argument for the "l33t" version. I can't even see how that's easier to read. Oh, and unless you're commenting a description of IsUsrValSys every place you use it you're basically going to rely on the IDE to pop the declaration and the comment that goes with it (again, I'm a Visual Assist whore). That's not easy to read code, that's a decent IDE feature.
I'd love to see some of these contracted-variable-name folks deal with their code outside of a syntax highlighting IDE.
Admin
bows to the word wizzard
Admin
Here are two more WTFs that no one has pointed out yet:
WhyTF is permission logic duplicated in each user object, rather than centralized in a singleton?
WhyTF aren't we minimizing the number of object calls?
int[] RenegotiateActionSteps = {Security.CompleteClosing, Security.InitializeClosing, Security.CompleteApproval};
boolean CanRenegotiateAction = Security.IsPermitted(CurrentUser, RenegotiateActionSteps);
Admin
sesquipedalianism: The at of using words more complicated then necessary. Essentially it word is an sesquipedalianism.
Now for the length of the variable names, I do think they are far to long. We have OOP for a reason. Instead of his CheckPermissionsForAl....etc he should have made a class so he could instead say this:
Allowed = Permissions.Action(UserID)
Or somthing close to that. Still very descriptive without all the novel length variable names and follows the ideas of OOP. Permission based checks should be handle by a permissions class rather then scattered willy nilly across the application.
Admin
Some people just type really really fast without ever making a mistake. The code given is about as self documenting as is possible.
Admin
Maybe it's a language-specific uniform...
Admin
This is another case of not using OOP. Where is your user class? Why not this:
User.System.Validated(System.Name)
Use your system class, use your user class. User can contain an instance of system easily.
Admin
The problem isn't so much the long variable names, it's long variable names that are almost the same.
hasPermissionsRequiredToCompleteSigningStep hasPermissionsRequiredToInitailizeClosingStep hasPermissionsRequiredToCompleteApprovalStep
the length of these variables makes it harder to pick out the important part of these variables, and most of it doesn't add any clarity to the variable's purpose.
That combined with the excessive comments for a simple bit of code, If every line of code has a comment explaining what it does on the local scale, it gets harder to find the comments that describe what is happening on larger scales.
Admin
THERE.
(I feel better now.)
Admin
That's right in line with this:
CHEERLEADER, SO AND SO: a B'GRL PRTY?!?
WHAT'S HER FACE: Taking the vowels out of words doesn't always make them cool.
SO AND SO: 'm srry.
Admin
Reminds me of an old joke about student using labelA: labelB: in program and being told by proffesor to use long mnemonic identifiers instead. So he changed them to longMnemonicIdentifierKindaLabelA: longMnemonicIdentifierKindaLabelB:
Admin
Odd.
I thought the WTF was that the company took the 'Java Wizard' and made him code in VB. If you've got a Java Wizard, wouldn't you have him code in Java?
Admin
Exactly. Now replace that with:
canCompleteSigningStep canInitailizeClosingStep canCompleteApprovalStep
Half the size, just as much information.
Admin
Oh, see, I agree with that. I was disagreeing with the really short naming.
Side point, a couple of people have mentioned use of classes. Whilst that's a valid comment as far as OOP coding is concerned (and I don't code java, so I won't comment), it doesn't have any bearing on variable naming length/convention discussion. Yes, using the class name to absorb and scope the variables is fair enough and good practice but you can still have long/short/whatever member naming. So ignore OOP coding for the moment, I think the variable naming style should be considered as if it were a vanilla C, scope-free question.
Point in a sentence: User::IsValidatedAgainstSomeSystem -v- User::IsValSys.
Admin
This is right. But aren't the comments the biggest WTF? They add nothing to the code. They're like our favorite types of comments:
i = (j % m); // set i to j mod m
Given the long names (which could indeed have been chosen better) the comments should have been removed, or replaced by
// Get permissions as shown below
There is one advantage in having such similar names, by the way. When listing them out alphabetically, the related names will sort together.
This all looks like a pseudocode-writing exercise where business process elements are getting named according to some development methodology. The methodology probably specifies rules for how names are constructed and what comments should be used. It may or may not have actually been intended to survive as production code.
Of course WTHK what was going on in those big project meetings? Or in the Wizard's head. The later history does make the whole thing amusing. Though a Big IT architect, trying to code up small-company software, is going to be a fish out of water. He still might have been a good Big IT architect.
JMO
Admin
!!! LOL !!!
Admin
Yes, because as we all know, changing the code so that it is better optimized it is a Good Idea. Especially when it's a microoptimization, we haven't run profilers on it, and we haven't even looked at the context it's being used in to determine how frequently it's called. The fact that the change would (IMO) hurt readability only serves to seal the case in favor of optimizing it.
(I'm being somewhat facetious here, especially because a properly indented bigLongStringThatIDon'tWantToHitBackToFindOutWhatItIs && withTheActualFunctionCallsRightHere && asYouAreSuggesting is not too much harder to read than the version with separate bools. That said, I *do* think the version with separate bools is easier to read. The difference would be much less if the names were a bit shorter (but the guy who said he wants 8-character identifiers back is, IMO, nutso; I only need point you to 'umount' for a demonstration of the type of annoyance that can cause), but even then I think it'd be improved with separate variables, mostly because it makes the purpose of each clause explicit.)
Admin
My guess is that this java wizard is actually a java alchemist, who occationally makes something useful, but it's usually the some-thing-not-so-useful came out of it most of the time.
Documenting the code is a good practice, but this seems to overkill.
Still, good saturday-morning laugh.. hehe..
Admin
import static com.corp.Permissions.*;
public boolean hasPermissions(User user, Permission ... permissions);
if(authorizer.hasPermissions(user, CompleteClosing, InitializeClosing, CompleteApproval)) {
// foo
}
Admin
Might have retired? That sounds a bit like when was like in highschool when I accidentally set a girls hair on fire and then decided to change schools because i was "asked to leave" by the principal.... some might say i also retired from that school.
Admin
While the prolific names are a lesser evil compared to the inscrutable, indecipherable garbage of which a lot of selfish programmers are guilty, I've found that people who use eight-word variable names and method names are usually doing it to get out of the responsibility of having to document those variables and methods. They just try to put the entire "documentation" into the name.
Admin
Oh, Brother! Let me know when you get your degree. Then send me your resume so I can call you in for an interview and BITCH-SLAP you up the butt.
CamelCasing is easy to read. Underscores are for girls.
Admin
Bahah, no-one has noticed that VB is the only language to get an evil-sounding title. Thing back to the viceroy in star wars, its well deserved too.
vb = crap
Admin
Finally_an_argument_that_is_useful. I'm_now_an_underscores_only_man. From_now_on_when_I_see_camel_case_I'm_fixing_it! Granted_there_are_only_a_handful_of_girls_programing_(exclusing_Paula). That_just_means_I_have_to_work_harder_to_attract_one.
Admin
My on-topic comments rarely get reactions, but I post one deliberately silly sentence and get a whole stream of reactions .... ;-)
If we're being pedantic, the word sesquipedalis was (I understand) used in Latin to mean literally one-and-a-half feet, but can you produce an example of sesquipedalian being used in English to mean that? I've never met it being used in other than the sense of verbose, even in eighteenth-century literature.
Admin
What I'd really like to know is why he's using a static variable,that can be accessed anywhere in the jvm via the classname, as a method parameter. At best it adds no value, at worst it means that he has no idea how static variables work.
In light of the rest of the post I get the sneaking suspicion that the latter is the case, and it makes me wonder whether this particular 'java wizard' meant for 'SpecificApplicationPermissions.CompleteClosingStep' to be an instance variable.
Whatever the case, he hasn't doco'd why he is being an apparent tit, which I suppose is another wtf.
Admin
Admin
"Their"
i before e except after....oh wait...
I have to agree though, I dislike American spellings a lot of the time. I do have a strange ability to switch between "color" when programming and "colour" when not though. I do a lot of UI work, and thus use a lot of Americanised graphical API's, so I just use "color" to be consistent.
Admin
Indeed. Yet again, the article is the WTF.
And yes, misspellings in code annoy me, but sometimes you have to work with stuff that's already misspelled and keep using those misspellings. Sometimes, too, the articles on here are 're-created', so perhaps the misspelling is due to the submitter or editor.
The Java code is great - I might have replaced 'hasPermissionTo' with 'may', but I found it obvious what the code does at first reading, which is extremely important IMO.
Admin
Maybe he meant that he needs permissions to be in Italy?
-dZ.
Admin
Roget's Thesaurus? (nice touch, wink! wink!)
-dZ.
--
CAPTCHA: captcha
wtf??
Admin
I'm not against CamelCase entirely - mostly because everything in Java already uses it. It's the really long identifiers in CamelCase that I don't like. I can just about tolerate ArrayIndexOutOfBoundsException, but anything longer than that, repeatedly, is just asking for eyebleed. Especially if it has, as pointed out, words that don't add anything remarkable, like "Required", "Interactive" and "Specific" here.
And yep, a method's local variables should rarely be longerThanThis and loop counters, temporary values, etc. should not really go beyond that 8-letter limit, lowercase, unless it's really warranted.
Anyway, let's compare:
"Array index... out of bounds." Got that. Java library designers get to the point. Good for them.
"Has permissions required... to complete... approval... step." Why not "canApprove"? Someone noted that "has" is used consistently here; why not use consistently "can" to mean "has permissions for"? (Think of Hungarian warts, when used properly.) "To complete the approval step" is corporate speak that's not likely to get past a book editor, and the wording "approval step" requires thinking of the entire structure of the program rather than the task at hand - and here's the notable thing, we're not doing any other "approvals" here. (If we were, we could use canApproveBilling and canApproveShipping or whatever.) So, "can approve".
Admin
But you know that "Darth Debugger" is already taken :)
Admin
Current user can also be non-interactive.
Ever heard of a rather amusing POSIX error ENOTTY, often reported by the operating system as "Not a typewriter"? (Though GNU C library seems to report a little bit more boring and accurate message "Inappropriate ioctl for device.") Basically, triggered when the application treats stdin/stdout (or any other file handle) specifically as a terminal (attempting terminal controls via ioctl()) without realising it's actually reading from/writing to a pipe. A handy library call to find this out is isatty() in unistd.h.
Though I hardly expect all this to be relevant in this case =)
Admin
That's not a problem with underscoring so much as it is just really freaking stupid. (Not to mention undefined in C and C++; names starting with a double underscore or underscore followed by a capital letter are reserved for implementation use.*) I mean, people can make identifier names like l1l11ll1 and ll111l11 or O0OO0 O000OO that are just as hard, but I haven't heard any complaints that identifiers allow numbers in them.
I think if you went through and replaced all camelCasing with underscoring code would improve in readability. I don't think it would help tremendously, because shorter identifier names are pretty readable in camel casing.
(I also think this particular example would be almost as hard to deal with as __z and ___z.)
* Contrary to popular myth, my reading of the standard is that names starting with an underscore then number or underscore then lowercase letter are legal.
Admin
Who needs digits? Just mix lowercase L with uppercase i to get names like IIllIlII and llIIllII. Best used in boolean "or" expressions (in C-like languages):
lIIllIIlI = IIllIlII || llIIllII;
Admin
All C programs are ONE line. As are all HTML pages.