- 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
try { checkForwardEmail(); } catch (First t) { String msg = t.getMessage(); if (msg != null) { msg = msg + ""; System.out.println(msg); } }
Admin
Instead of catching a generic class, let's catch something EVEN MORE GENERIC!
Admin
Admin
I wonder what the anonymous submitter replied to that...
Admin
Tip
Learn how to format a try/catch block correctly
Admin
TRWTF is that he's actually willing to learn and accept criticism. The second check in is probably a combination of lack of experience and bad/unspecific advice (anon obviously didn't explain why the things Joe did wrong were actually wrong)
Admin
This is BS. Now we're making fun of people that are unexperienced programmers? Pff, lame.
Until recently there was really bad code where you had to wrap your head around to get what was wrong. Now it's just newbies we're laughing about? I'm done here...
Admin
The real WTF is probably that a project manager is "helping" by submitting code into the repository, even though he knows nothing of Java.
Admin
I'm still wondering what was he hoping to achieve with msg = msg + "". Maybe some old reflex that got to him on some other development platform?
Admin
What I want to know is whether JIRA-381 had anything to do with this code, or with error handling. I.e., could Adolf have given advice which was a little more relevant.
Admin
Tagging the code itself with the name of the bug that was fixed, and the name of the person who fixed it. Especially when you have a code repository.
Admin
TRWTF is that this was submitted at all.
Admin
Admin
Furthermore, the line 'msg = msg + "";' is still in there, which is meaningless in Java as Java is a strongly typed language.
On the plus side, CmdrJoe did indeed something meaningfull when catching the exception, although error handling like "System.out.println(msg);" leaves some room for improvement.
Admin
Numpties and duvelopers, no wonder production DBAs are hated
Admin
Admin
Oh yeah, I see TRWTF: he's mucked up the indentation.
Admin
We have over 7000 items in Jira for just one of our products. I really don't need to wade through that many useless comments in the source code.
Admin
"catch(...){}"
Come on, who hasn't done that at least once.
Admin
Thanks guys, I knew that. Now I have to dig for those five minutes to understand what the change was, if it is important in the context of what I'm doing in the code, and maybe things like whether someone else changed it afterwards, or before, or whatever; or what the problem was that provoked the ticket that provoked the change.
No. Don't do that. If the changed code has some level of fragility, or if there is a reason why it is like it is, explain that - in words, not ticket numbers - and only then give a reference to the ticket. (Finding out who made the change is of use primarily if you are playing the blame game, except when you need to ask the culprit (there's that blame game again) what his reasons were...)
Admin
If something's really self documenting, no comment is better than any comment.
On the other hand, if that code was self documenting, there wouldn't be a discussion on what's its purpose here.
Admin
To be "better" than no comment the comment needs to: a) provide more information than you can see at the first glance on the code (If the comment contains the same information than the code: how can it be "better" than no comment?) b) add correct information! (if the comment contains incorrect information, it definitely would have been better to leave it away completely)
Admin
I wish I would be exaggerating, but his programs were littered with these! Still having nightmares about this abomination...
Admin
As always, TRWTF is Javascript.
Admin
How do you comment if you have to fix a failed fix? When will the fix be part of the codebase thus comment loses importance? Who will remove it then? What will be the commit comment to explain it?
If you have JIRA and some other ALM tools, you might want to integrate them. There are products that will then show you a JIRA issue, what was committed to the repo to fix it, highlighting the changed lines. Easy. But you may want to stay at commenting changes in source and be TRWTF.
Admin
At the very least you can log that there was an exception and kill the thread. Then whoever has the task of doing something about the issue will have an indication of which function call threw the exception.
Admin
No rules? People will submit checkins with no checkin comment, and comments like "fix problem" in the code.
No empty commit comments allowed? People will submit this comment:
Regexes to guarantee a minimal format? People will submit this comment:
(or whatever other minimal commit comment is required to pass the filter).As I've said elsewhere, you can't fix stupid. You can't fix willfully subversive either, except by disciplinary procedures.
Admin
Well, either you have millions of line of code (in which case 7000 comments will hardly be noticeable), or your company writes really buggy code if you're having to 'wade through' these comments...
Admin
Admin
Come on, the RealWTF is using XML for a freaking comment. I mean, XML!!!
Admin
If it takes you 5 minutes to find the history of a file in your VCS, you are TRWTF. These comments are pure line noise. Any half-decent VCS will show you who modified a line and even provide a nice graphical diff to the previous version at the touch of a button.
Admin
Why is there a discussion of the purpose of a try/catch?
It was pretty obviously intended to wrap a failing function. Everything else is implementation details, and we don't know what the called function does, so there's no point speculating.
Whether or not this is the appropriate place to stick this block is a different discussion entirely.
Admin
Sure. Once you've ALREADY figured out which commit you need to find. If you are looking at something from two years, ago, there may be quite a few revisions to wade through before you get there. Whereas if the block of code you need to investigate is helpfully tagged with the ticket number and name of the person who wrote it, you can either look up the ticket or look up the person and get most of the information you need.
Admin
(*) or its more hostile cousin, svn blame. (**) See, I told you it was more hostile.
Admin
Abomination indeed. It should clearly have been
Admin
Yes, you can find out who added what by looking at version history. However, our code repository is about 10 years old and most of our files have 50+ revisions, some with 200+, talk about a needle in a haystack. Again, this is something that you can't apply a blanket statement to, it is more of a case-by-case basis.
Admin
"The definition of insanity is doing the same thing over and over and expecting different results."
Admin
Admin
Admin
Or you see these, from a person that preceded me:
-no me gusta. -interesting, very very interesting. -There you are, take THAT! -being very careful with [revision] -[revision] DEAD, something else, maybe. -dales dead bugs. -oops. -out with the old -in with the new -wack -stamp -stupid log message -ah geez
(yes, these are all real)
Admin
Awww, c'mon: he clearly used this as a "Wait until the method works," loop. Some outside event will happen sooner or later to bring success.
Admin
Steve, all of those things can be controlled.
You: Your last 5 commit messages were ".", "lol", "NOT THE BEEEES", "fix" and "real fix". Developer: and? You: You're fired.
It's quite easy to ensure good quality processes, warn them first, if they don't mend their ways then give bad performance reviews (and hence pay rises and promotions), and ultimately, fire people if they still don't follow them.
TBH most commit hooks are for your benefit. Eg, if you don't add a case number in your commit, then your ticked doesn't get updated automatically, it doesn't get marked as ready for testing when deployed to test, and it doesn't get marked as done when released. The commit hook prevents you from having to do that work (and besides, our commit hooks are such that if you commit the same change twice with the same message, failed commit hook or not, it goes through)
Admin
Everybody is inexperienced at first, but when I was a neophyte programmer I read books and so on to improve my skills - I still do.
I've met programmers who had over a decade of experience in a language who didn't really understand the basics of that language, who thought that this particular code (which I see examples of every day in my current project) is fine and recommended.
Admin
TRWTF is that he didn't close the markup tag in the revised checkin.
Admin
Admin
His IDE was probably warning him that msg was an unused variable.
Admin
Admin
You didn't carry out your experiment far enough. If you flip it twice again, you will get heads, then tails again. This occurs in order to satisfy the "law of averages".
Admin
TRWTF is that someone named their product's project "JIRA" in the Jira.
Unless this is actually from the source code for Jira itself, in which case it would explain a few things.
Admin
Also, Flipping a coin has a predetermined number of possibilities. If you flipped a coin, you will get heads or tails. If you flip the coin and the outcome is, say, Velociraptor, THAT would be insanity.