Comment On The Pesky "e"

"As a general rule of thumb," writes Newman, "we ignore all build warnings. After all, the code complies... so why bother worrying about warnings?" [expand full text]
« PrevPage 1 | Page 2 | Page 3 | Page 4Next »

Re: The Pesky "e"

2011-07-06 11:07 • by Justice
E is for Exception and that's good enough for me. OM NOM NOM!

Re: The Pesky "e"

2011-07-06 11:08 • by Dude (unregistered)
I hate those pesky e's. I had to get rid of them all over my codebase too. It didn't do much for the application, but it builds a little faster now....

Re: The Pesky "e"

2011-07-06 11:15 • by no u (unregistered)
this is still dangerous code. To make it truly safe it needs a

 finally {} 

Re: The Pesky "e"

2011-07-06 11:17 • by frits
352438 in reply to 352433
Justice:
E is for Exception and that's good enough for me. OM NOM NOM!


+10. That's awesome!

Re: The Pesky "e"

2011-07-06 11:19 • by frits
All this talk about "e" is going to attract all of those discotheque-crazy Europeans from yesterday's comment thread.

Re: The Pesky "e"

2011-07-06 11:20 • by steenbergh
It's the Bad Code Offsets you and your team buy each month that keep the Apache project running isn't it?

Re: The Pesky "e"

2011-07-06 11:22 • by hoodaticus
How about an extension method to teach these people what to do with exceptions? I use ex.Log(), which uses a static, configurable ErrorLog class to log the full stack trace and everything else to the EventLog, and emails the same to the developer.

Re: The Pesky "e"

2011-07-06 11:23 • by hoodaticus
352442 in reply to 352437
no u:
this is still dangerous code. To make it truly safe it needs a
 finally {} 
I never knew you could combine that with catch {}. I guess you unlearn something new every day.

Re: The Pesky "e"

2011-07-06 11:24 • by callingFoul (unregistered)
What language is this? This wouldn't even compile in Java without the 'e'.

Re: The Pesky "e"

2011-07-06 11:25 • by StupidTheKid (unregistered)
Oh, how I wish this story was fake... We were asked to do the same in our codebase; to remove all compilation warnings without changing behavior.

There is seemingly a market for software that behaves like a pack of rabid werewolves.

Re: The Pesky "e"

2011-07-06 11:26 • by RHuckster
DoProcessReceipts() just looks like a long-ass 100+ line function that does SQL queries, array manipulation, and a ton of other operations that can be prone to all kinds of exceptions. I can't believe there isn't even a log entry for when something goes wrong.

Re: The Pesky "e"

2011-07-06 11:26 • by SCSimmons
352446 in reply to 352441
hoodaticus:
How about an extension method to teach these people what to do with exceptions? I use ex.Log(), which uses a static, configurable ErrorLog class to log the full stack trace and everything else to the EventLog, and emails the same to the developer.

You know, it's sometimes hard to tell around here when someone is pulling your leg in the comments. So I think I'll just sit back and let this sail on by ...

Re: The Pesky "e"

2011-07-06 11:28 • by Rawr (unregistered)
352448 in reply to 352443
callingFoul:
What language is this? This wouldn't even compile in Java without the 'e'.


It's C#, the 'joke' is that with the e you get a warning 'Variable e is declared but never used', so they removed it.

Re: The Pesky "e"

2011-07-06 11:29 • by The Nerve (unregistered)
Fixed?

try {
DoProcessReceipts();
}
catch (Exception e) {
// this should never happen
}

Re: The Pesky "e"

2011-07-06 11:29 • by Nagesh (unregistered)
This is standard programming practice in Hyderabad

Re: The Pesky "e"

2011-07-06 11:30 • by hoodaticus
352451 in reply to 352449
The Nerve:
Fixed?

try {
DoProcessReceipts();
}
catch (Exception e) {
e.ToString();
}
FTFY

Re: The Pesky "e"

2011-07-06 11:32 • by Britmaster (unregistered)
352452 in reply to 352439
frits:
All this talk about "e" is going to attract all of those discotheque-crazy Europeans from yesterday's comment thread.

You mean American Trolls masquerading as Europeans, right? Everyone in Europe is on Summer vacation for 3 months.

TRWTF is American labour laws.

Re: The Pesky "e"

2011-07-06 11:34 • by zunesis (unregistered)
352453 in reply to 352451
hoodaticus:
The Nerve:
Fixed?

try {
DoProcessReceipts();
}
catch (Exception e) {
Console.WriteLine("Error");
}
FTFY

Even better

Re: The Pesky "e"

2011-07-06 11:35 • by zunesis (unregistered)
352454 in reply to 352452
Britmaster:
frits:
All this talk about "e" is going to attract all of those discotheque-crazy Europeans from yesterday's comment thread.

You mean American Trolls masquerading as Europeans, right? Everyone in Europe is on Summer vacation for 3 months.

TRWTF is American labour laws.


No one reads the website from home?

Re: The Pesky "e"

2011-07-06 11:35 • by Tony Little (unregistered)
352455 in reply to 352443
callingFoul:
What language is this? This wouldn't even compile in Java without the 'e'.

Well, you eliminated one. Keep going, you CAN DO IT!

Re: The Pesky "e"

2011-07-06 11:37 • by frits
352456 in reply to 352452
Britmaster:
frits:
All this talk about "e" is going to attract all of those discotheque-crazy Europeans from yesterday's comment thread.

You mean American Trolls masquerading as Europeans, right?

It hardly makes a difference to me.

Re: The Pesky "e"

2011-07-06 11:37 • by C-Octothorpe
352457 in reply to 352446
SCSimmons:
hoodaticus:
How about an extension method to teach these people what to do with exceptions? I use ex.Log(), which uses a static, configurable ErrorLog class to log the full stack trace and everything else to the EventLog, and emails the same to the developer.

You know, it's sometimes hard to tell around here when someone is pulling your leg in the comments. So I think I'll just sit back and let this sail on by ...


No, he's serious, it's just that he's been 'Enterprised' (notice the use of a configurable log provider and extension methods).

Re: The Pesky "e"

2011-07-06 11:37 • by hoodaticus (unregistered)
352458 in reply to 352453
zunesis:
hoodaticus:
The Nerve:
Fixed?

try {
DoProcessReceipts();
}
catch (Exception e) {
Console.WriteLine("Error");
}
FTFY

Even better

You still get the warning that way, dummy. It should obviously be:

try {
DoProcessReceipts();
}
catch (Exception e) {
MsgBox(e.ToString());
}

...especially on a server.

Re: The Pesky "e"

2011-07-06 11:39 • by C-Octothorpe
352459 in reply to 352458
hoodaticus:
zunesis:
hoodaticus:
The Nerve:
Fixed?

try {
DoProcessReceipts();
}
catch (Exception e) {
Console.WriteLine("Error");
}
FTFY

Even better

You still get the warning that way, dummy. It should obviously be:

try {
DoProcessReceipts();
}
catch (Exception e) {
MsgBox(e.ToString());
}

...especially on a server.


... *after* calling office automation code! WIN!

Re: The Pesky "e"

2011-07-06 11:39 • by zunesis (unregistered)
352460 in reply to 352458
hoodaticus:
zunesis:
hoodaticus:
The Nerve:
Fixed?

try {
DoProcessReceipts();
}
catch (Exception e) {
Console.WriteLine("Error");
}
FTFY

Even better

You still get the warning that way, dummy. It should obviously be:

try {
DoProcessReceipts();
}
catch (Exception e) {
MsgBox(e.ToString());
}

...especially on a server.


The idea was that you get an error message, but none of the helpful information that was in the exception. The message box on a server has been covered.

Re: The Pesky "e"

2011-07-06 11:41 • by C-Octothorpe
352461 in reply to 352453
zunesis:
Even better


That actually is better (at least there is *something* being outputted as opposed to the silent scream of a caught exception), but you'll still get the compiler warning.

Re: The Pesky "e"

2011-07-06 11:42 • by SeySayux (unregistered)
Next time you bash e, get to know it first. Thanks.

Re: The Pesky "e"

2011-07-06 11:46 • by Ryan (unregistered)
Hooray for compliant code! 'Cause the non-compliant variety is just too much for me, you know.

Re: The Pesky "e"

2011-07-06 11:47 • by Justice
352464 in reply to 352461
C-Octothorpe:
the silent scream of a caught exception


Is that a concept from Lovecraft-Driven Development (LDD)?

Come to think of it, the majority of code seems to be based on primal terror.

Re: The Pesky "e"

2011-07-06 11:48 • by boog
Embarassingly enough, it eluded everybody that every error and exception would endure even after eliminating the pesky "e".

Re: The Pesky "e"

2011-07-06 11:52 • by hoodaticus
352469 in reply to 352446
SCSimmons:
hoodaticus:
How about an extension method to teach these people what to do with exceptions? I use ex.Log(), which uses a static, configurable ErrorLog class to log the full stack trace and everything else to the EventLog, and emails the same to the developer.

You know, it's sometimes hard to tell around here when someone is pulling your leg in the comments. So I think I'll just sit back and let this sail on by ...
At a minimum, I like to know what part of my code throws exceptions so I can fix the problem.

Re: The Pesky "e"

2011-07-06 11:53 • by evilspoons (unregistered)
352472 in reply to 352466
boog:
Embarassingly enough, it eluded everybody that every error and exception would endure even after eliminating the pesky "e".


Some part of me wants to give you a high five... another part of me wants to smack you.

Re: The Pesky "e"

2011-07-06 11:54 • by dohpaz42
352473 in reply to 352466
boog:
Embarassingly enough, it eluded everybody that every error and exception would endure even after eliminating the pesky "e".


BUT, the point was not to fix the errors/exceptions, it was simply to remove the build warnings.

Re: The Pesky "e"

2011-07-06 11:54 • by C-Octothorpe
352474 in reply to 352466
boog:
Embarassingly enough, it eluded everybody that every error and exception would endure even after eliminating the pesky "e".


You mean the exception would still happen, but would still be swallowed by the empty catch, right? The way I read your comment was that it would bubble up...

Re: The Pesky "e"

2011-07-06 11:58 • by gobes
352476 in reply to 352452
Britmaster:
frits:
All this talk about "e" is going to attract all of those discotheque-crazy Europeans from yesterday's comment thread.

You mean American Trolls masquerading as Europeans, right? Everyone in Europe is on Summer vacation for 3 months.

TRWTF is American labour laws.


If only we had 3 monthes... in France we have only 2. CA c'est le vrai WTF.

Re: The Pesky "e"

2011-07-06 12:02 • by Robb (unregistered)
"As a general rule of thumb," writes Newman,


Helloooo NEWMAN

Re: The Pesky "e"

2011-07-06 12:17 • by hoodaticus
352480 in reply to 352457
C-Octothorpe:
SCSimmons:
hoodaticus:
How about an extension method to teach these people what to do with exceptions? I use ex.Log(), which uses a static, configurable ErrorLog class to log the full stack trace and everything else to the EventLog, and emails the same to the developer.

You know, it's sometimes hard to tell around here when someone is pulling your leg in the comments. So I think I'll just sit back and let this sail on by ...


No, he's serious, it's just that he's been 'Enterprised' (notice the use of a configurable log provider and extension methods).
Yeah, I'm about as enterprisey as it gets. I've discovered that my code gets more maintainable when I have proper abstraction and domain models that describe my problems. And I've never seen non-enterprisey code that can read records from a database and package them into business objects, with exception logging, in a single line.

Re: The Pesky "e"

2011-07-06 12:19 • by hoodaticus
352481 in reply to 352474
C-Octothorpe:
boog:
Embarassingly enough, it eluded everybody that every error and exception would endure even after eliminating the pesky "e".


You mean the exception would still happen, but would still be swallowed by the empty catch, right? The way I read your comment was that it would bubble up...
I think he means that the exception wasn't actually handled. Of course, ignoring it is sometimes the answer.

For instance, my exception logger class has an empty try catch around the Log method, "//because exception loggers should not throw exceptions".

Re: The Pesky "e"

2011-07-06 12:24 • by C-Octothorpe
352482 in reply to 352481
hoodaticus:
For instance, my exception logger class has an empty try catch around the Log method, "//because exception loggers should not throw exceptions".


But... but... but... who's going to log the loggers?!

Re: The Pesky "e"

2011-07-06 12:30 • by Big Bother (unregistered)
352483 in reply to 352445
RHuckster:
DoProcessReceipts() just looks like a long-ass 100+ line function that does SQL queries, array manipulation, and a ton of other operations that can be prone to all kinds of exceptions. I can't believe there isn't even a log entry for when something goes wrong.

We've always been at war with Oracle.

Re: The Pesky "e"

2011-07-06 12:40 • by blarg (unregistered)

Re: The Pesky "e"

2011-07-06 12:40 • by zunesis (unregistered)
352486 in reply to 352461
C-Octothorpe:
zunesis:
Even better


That actually is better (at least there is *something* being outputted as opposed to the silent scream of a caught exception), but you'll still get the compiler warning.


I meant "better" as in "more ironic" but whatever.

Re: The Pesky "e"

2011-07-06 12:49 • by callingFoul (unregistered)
352488 in reply to 352448
Rawr:
callingFoul:
What language is this? This wouldn't even compile in Java without the 'e'.


It's C#, the 'joke' is that with the e you get a warning 'Variable e is declared but never used', so they removed it.


And there's TRWTF - assuming developers using a language will write shite.

Re: The Pesky "e"

2011-07-06 12:51 • by C-Octothorpe
352489 in reply to 352488
callingFoul:
Rawr:
callingFoul:
What language is this? This wouldn't even compile in Java without the 'e'.


It's C#, the 'joke' is that with the e you get a warning 'Variable e is declared but never used', so they removed it.


And there's TRWTF - assuming developers using a language will write shite.


Um, ok. I think you almost the comment...

Re: The Pesky "e"

2011-07-06 12:56 • by tragomaskhalos (unregistered)
352490 in reply to 352488
callingFoul:
Rawr:
callingFoul:
What language is this? This wouldn't even compile in Java without the 'e'.


It's C#, the 'joke' is that with the e you get a warning 'Variable e is declared but never used', so they removed it.


And there's TRWTF - assuming developers using a language will write shite.

Silently eating an exception is understandable (though not forgivable) in Java because the code won't compile without either the try ... catch or an exception specification (which then needs to be propagated to all callers). But C# does not have that problem so this is both both unforgivable *and* inexplicable !

Re: The Pesky "e"

2011-07-06 12:56 • by Dawn (unregistered)
352491 in reply to 352444
StupidTheKid:
Oh, how I wish this story was fake... We were asked to do the same in our codebase; to remove all compilation warnings without changing behavior.

There is seemingly a market for software that behaves like a pack of rabid werewolves.

Well duh, yeah... whom else would the software that behaves like a one-hundred year old vampire wistfully trying to overcome his darker nature while dating high school girls that are 85 years his junior have to fight?

Did I mention the vampire's handwriting IME is so beautiful and perfect?
No? Oh, well, it so totally is.

Re: The Pesky "e"

2011-07-06 12:57 • by Gary (unregistered)
I use this pattern all the time in javascript. Maybe I'm looping through an array and want to do something (call methods, change properties) that only some of the elements have. I'm too lazy to inspect each one, so I'll just try and catch.

Re: The Pesky "e"

2011-07-06 13:02 • by Lil Kim Jon Ill (unregistered)
352494 in reply to 352486
zunesis:
C-Octothorpe:
zunesis:
Even better


That actually is better (at least there is *something* being outputted as opposed to the silent scream of a caught exception), but you'll still get the compiler warning.


I meant "better" as in "more ironic" but whatever.

Ironic better is best better.

Re: The Pesky "e"

2011-07-06 13:10 • by C-Octothorpe
352496 in reply to 352486
zunesis:
C-Octothorpe:
zunesis:
Even better


That actually is better (at least there is *something* being outputted as opposed to the silent scream of a caught exception), but you'll still get the compiler warning.


I meant "better" as in "more ironic" but whatever.


I realized that, but wasn't sure if you knew that your example (although technically wouldn't compile) was actually an improvement.

Anyway, excuse me while I reboot my sarcasm detector...

Re: The Pesky "e"

2011-07-06 13:16 • by zunesis (unregistered)
352497 in reply to 352496
C-Octothorpe:
zunesis:
C-Octothorpe:
zunesis:
Even better


That actually is better (at least there is *something* being outputted as opposed to the silent scream of a caught exception), but you'll still get the compiler warning.


I meant "better" as in "more ironic" but whatever.


I realized that, but wasn't sure if you knew that your example (although technically wouldn't compile) was actually an improvement.

Anyway, excuse me while I reboot my sarcasm detector...


After all the times I've been ribbed on this site...
« PrevPage 1 | Page 2 | Page 3 | Page 4Next »

Add Comment