- 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
I never get tired of these.
Admin
Oh if only it was as easy as typing "// handle errors". How much easier would my life be?
Admin
a wrapping CSS class that doesn't wrap, and a non wrapping one that wraps !
Pure genius !
As a side note, i think that the last one had already been posted here
Admin
"Brillant!"[;)]
Admin
This isn't necessarily superfluous. Can't you call a function by reference in VB?
Admin
Obviously because it was my son's second birthday. Duh!
Admin
Ah, the empty catch block...the C# version of VB's On Error Resume Next...
Admin
Maybe Status == Success means it successfully failed...
Admin
<FONT face="Courier New" size=2>i've actually seen a 53 line java switch statement along those lines back in college (i call it the 'corpulent' toInt method). it was a junior-level class, however, so it was just kind of sad and pathetic. i didn't feel like explaining basic concepts, so i just commented out the switch and replaced with the one-liner and a comment that was like: // <initals>: we fixed the glitch! i really wish i could remember what his default case was. i think it was just to return the value that A or Z was supposed to have.</FONT>
Admin
Possibly negatively so.
Your Manager: Mr. Anonymous, we have a program that can do what you do, so we no longer require your services.
Sincerely,
Gene Wirchenko
Admin
<FONT face="Courier New" size=2>encapsulation: it's not just for ravers anymore. [<:o)]</FONT>
Admin
Should you really have a hyphen when using bicapitalisation?
If you are concerned about different character sets and wish a general solution, this would be the way to go.
Obviously, the answer is both!
Sincerely,Gene Wirchenko
Admin
It's probably debugging code that didn't get removed. I've done this kind of thing before, you notice that something goes wrong in the middle of a long loop when you hit a certain value and need a statement on which to set a breakpoint.
Admin
Don't debuggers usually have conditional breakpoints?
Admin
How is BeginDate = BeginDate going to set a breakpoint?
Admin
I think he's referring to placing a breakpoint inside of a conditional statement that coincides with when he wants to break.
A simplistic example would be
if(debugCondition)
{
// you could put a breakpoint here so that it breaks only when the debug condition is met
DoSomething();
}
It would be easier than placing a breakpoint on something that gets hit everytime. As far as conditional breakpoints, I've never seen them in Visual Studio .NET, but I wouldn't be surprised if they exist. Other IDEs I would have no clue about.
Admin
Only if you put it in a box and don't look at it.
Admin
Yes, but I usually slap
in there and tell it to break on that line, then step through the rest of the code with an immediate window open.Admin
No, no, no. Of course the value of "Status" tells you where to go to find out if it was successful. It's the column name!
(java usage supplied)
String where = rs.getString("Status");
//where = "Success"
String successOrFail = rs.getString(where);
Admin
Sure, and usually they can't evaluate much more than built-in types, or have interfaces that are harder to use than typing 3 lines of code.
Admin
I do that from time to time and I even checked one in so I could be the other of this WTF. And the reason is to avoid conditional breakpoints. Conditional breakpoints really slows down the program so recompiling with the condition in the code can be faster.
Admin
Ah, I see. Thanks for clearing that up for me.
Admin
Visual Studio v6 has conditional breakpoints so I assume VS .NET has them too. They are not particularily easy to us in v6 however, and its generally faster just to add an if block and set the breakpoint inside it.
Admin
Admin
Furthermore, anyone who's ever used a conditional breakpoint knows that they slow down the program tremendously, because what happens behind the scenes is this:
If the particular code in question happens to be in a loop where it'll be passed by a few hundred thousand times before getting to the value in question (usually the point where it breaks), using a conditional breakpoint can mean waiting several minutes instead of several seconds.
Admin
Gah. Who wrote this forum software? Don't they know that the point of a PREVIEW is to, well, take a look at what your post is going to look like when it's posted?
Admin
Well of course! What happens if MS decides to change the implementation of the Is Nothing command? You wouldn't want to have to go back through all your code and change it, would you?
Admin
The unix man page for the 'false' command simply says " false - do nothing, unsuccessfully" and 'true' says "true - do nothing, successfully" which are both pretty hilarious. Of course, my real favorite is the message you get when you type "%blow" at a bash prompt.
Admin
This is the biggest, most common WTF ever. I hate when people do this.
Admin
Instead of setting a conditional break point, the programmer typed this statement and set the break point within the IF statement. That way, the debugger will stop at that point only when the value is equal to the one specified within the IF statement.
I used to do that when I was new, and still do that when I'm in a hurry or trying to prove a point to someone.
Admin
VS.NET 2003: Open Breakpoints window, select breakpoint, click on "Properties", click on "Condition", et voilà.
VS.NET 2005 Beta 2: Right-click on breakpoint marker, select "Condition".
Admin
Admin
Maybe successful steps, failed transaction? Un-normalized data? Or maybe it's just software for "Opposite Bank Inc."
Admin
I guess. I don't really use debuggers much. To me they are just a waste of time. I've also had too many experiences where the debugger changes how the code executes.
Admin
I use a debugger (Eclipse) all the time and have never had this happen. Plus, hot swap of deployed code is a huge time saver.
Admin
Admin
I had a co-worker arguing with me about the value of debuggers once. Then he came to me and told me my code wasn't working. After about 30 minutes for me and hours for him we determined the debugger was causing the problem.
Personally, I prefer good logging. Debuggers are almost useless with multithreading bugs and don't help with production issues. If the logging doesn't give enough info to solve the problem, then the logging needs to be improved anyway. Debuggers encourage laziness. The only time I use them is when I'm having a brain-fart and need a sanity check.
Admin
So do text editors. Real programmers use cat.
Admin
I never suggested 'real programmers' don't use debuggers. I just personally find that I can solve more problems faster with good log/debug statements. I used to use debuggers a lot but I don't even think about it anymore. I any event, when the code is running in production, I don't have the option of opening up a debugger anyway.
Admin
Who says you can't have both?
Admin
I'm just not a fan of continually bouncing an app server for trivial code changes.
Admin
You just mentioned hot-swapping. Generally, I would try to debug on my desktop if at all possible. What I've found is that developers that use debuggers tend to put substantially less debug statements and comments in their code than those who don't. It's purely anecdotal but I think there's a reasonable causality there.
One question, though, are you suggesting that you run a debugger on code in the app server?
Admin
What I've found is that developers that use debuggers tend to put substantially less debug statements and comments in their code than those who don't.
This is definitely true, but I'm not one them. I have a habit of writing substantial comments and logging everything. Many of my colleagues don't have such habits. <o:p></o:p>
One question, though, are you suggesting that you run a debugger on code in the app server?
Not just suggesting...declaring.
Admin
I really can't fathom that point of view. Admittedly, if post-mortem analysis of bugs (in a production environment, or with hard-to-reproduce bugs) is required, logging is the only way. But in any other case, a debugger IMO speeds up debugging by a factor of at least 5 even if you have good logging. As for debuggers changing how the code is executed - logging statements inserted while hunting a bug do the same thing.
Admin
Question, then. If I want to attempt to call a function, but don't care if it throws an exception and fails, how SHOULD I do it? Admittedly, I'd prefer to see some logging done inside the catch statement, but I have code that looks almost exactly like that: it attempts to send out an email to our server team if certain errors are thrown. However, I don't really care if the email isn't sent, and I don't want to propogate the email exception upwards, as I'm already attempting to recover from another, more important type of error, and I don't have much to do if the "I'm broke" email doesn't get sent, other than what I was going to do in the first place.
Admin
Easy... don't call the function at all.
Admin
Ahh...indirection. Very clever.
Too bad they couldn't abstract it so that a failure was reported as successful.
I have a confession to make: I work at the same company as the poster of this WTF.
In fact, it was my predecessor who coded this gem. I guess I have to fix it....but how?
Admin
LOL! Great response, Maurits.
The real answer is, of course, simply call it. Don't wrap it in try/catch at all.
When an exception is thrown, the stack is unwound until an appropriate catch block is found.
If one is never found, the app just crashes. So maybe "you" don't care if it fails, but hopefully somewhere up the line, somebody does.
Admin
--quote--
"Brillant!"
--/quote--
That was my line lol [:D]
Admin
You should note that running in a debug mode on a production server is a HUGE waste of resources. All sorts of code checks and debug methods are ADDED by whatever IDE you are using. If you are running debug modes on production clients you should be shot. Debuggers are for development purposes, not production bug tracking. Logging exists to help identify problems on production apps.
Now, logging is not meant to log every activity on production; that is why plug-ins such as Apache's log4j have different levels of logging. You have debug logging for development issues, then info/warn/error logging for production and live state tracking. Logging in production is supposed to give a general idea of the flow/state of production app and give as much clue as possible as where problems are arising. I am not talking about logging things that are used for business purposes of course, such as credit card transaction logging.