|
It once took me 2 days! to track down a bug because someone had decided to swallowed the exception catch { } . The problem is some programmers just don't get it.
The best article I've ever read regarding exception handling is Exception Handling Best Practices and it's on CodeProject.
"You get that on the big jobs."
|
|
|
|
|
|
Hi Naerling,
The problem is you may not be aware that it is an exception that is the problem. In this case it smelt like business logic because no exceptions where being thrown or logged.
The Exception window is a great tool. It can be found in the menu bar under Debug, Exceptions...
"You get that on the big jobs."
|
|
|
|
|
Actually, the catch that said 'Do nothing, if the form does not start you will know soon enough' (see a previous post) did nothing because some forms were started and disposed immediatly, or gave the user the option to end it while it was still loading. This, of course, gave an exception. But because it was meant to behave like that the programmer did not want to do anything with the exception... So when I fixed it by showing a messagebox and logging the exception I actually got told to undo my changes because 'the business logic was designed that way'! How about that for business logic?
It's an OO world.
|
|
|
|
|
RobCroll wrote: The problem is some programmers just don't get it.
Unfortunately, it's usually the customers who don't get it.
Our code is full of this "non-specific" error handling - not because we are bad programmers, but because customers don't want to see error messages (we've had complaints, such as "It's telling me that the socket has refused the connection! I don't want to see it!"). To me, that is stupid - I'd rather see a problem instead of sitting around wondering why something isn't working. On the other hand, we work a lot with real-time data, so customers don't want it constantly stopped by dialog boxes intimating that their system is badly set up (as it usually is)!
At least all our exceptions are logged - a small scrap of comfort for us.
|
|
|
|
|
Some of the exceptions I get I don't understand! So what chance does a user have. They just don't understand the message.
I like to encapsulate the error message in the business layer and throw a more user friendly error message to the presentation layer “Could not save customer information because computer networks are down.”. Users understand that. They have no idea of what a TCP/IP socket is but they understand that networks aren't always working.
That's the problem. It's not that there is a problem but the the message is meaningless. They don't understand the message.
So whether you are implementing MVC or MVVM or whatever, at some stage you need to consider the message the user gets.
Once they understand the problem, it's all cool... “see your Systems Administrator”. Now who the hell is that?
BTW that small scrap would be a life saver.
"You get that on the big jobs."
|
|
|
|
|
I guess that's why they invented the option in the debugger to break on any exception being thrown.
There is no failure only feedback
|
|
|
|
|
Few days ago I just reviewing some codes on a project and I found that there are too may commented unnecessary codes in each file.I am giving you all an example:
public virtual bool TraverseRecord(string TraverseFor, string Id)
{
bool HasRows = false;
string sql = "";
sql = "SP_NAVIGATE_CHILD_T '" + TraverseFor + "', '" + Id + "'";
iMHUtility.ExecuteStoredProcedure(sql);
if (iMHUtility.IsErrorOnExecution() == false)
{
if (iMHUtility.HasMoreRecords())
{
HasRows = true;
ValueInitialize();
}
}
return HasRows;
}
Look at the TraverseRecord, the first one is definitely useless, so why some programmers leave those useless lines as comment. I think this is disgusting.
|
|
|
|
|
I've seen similar stuff in places that for some unknown reason didn't use source control, but rather comments as a versioning mechanism. (No, that place is no longer in business... Surprise) The OP probably just copied and pasted it with the intention of modifying the code, but in this case I think he forgot to perform the latter.
I wasn't, now I am, then I won't be anymore.
|
|
|
|
|
Thats why code source control and review is important.
|
|
|
|
|
Someone give them a git or svn already, srysly >_>
|
|
|
|
|
Where I work we have classes that consist for about 50% of code like that. And that while we use SVN :p
I guess some people just do not dare to delete code. And probably you would not dare either if you worked at my company
It's an OO world.
|
|
|
|
|
A place I worked at had the same thing because they didn't have any form of source control, once I got them to implement source control most of this sort of stuff was cleaned out.
This particular code may also be the result of someone who doesn't "trust" source control and thinks that this is a better option, of course than person is a deluded fool but you never know.
People are more violently opposed to fur than leather because it's safer to harass rich women than motorcycle gangs
|
|
|
|
|
I have seen that happen because some people either do not understand what source control is or do not trust it.
|
|
|
|
|
It's really disgusting. At least they might comment only the particular line instead of whole thing & new copy of that.
public virtual bool TraverseRecord(string TraverseFor, string Id)
{
bool HasRows = false;
string sql = "";
sql = "SP_NAVIGATE_CHILD_T '" + TraverseFor + "', '" + Id + "'";
iMHUtility.ExecuteStoredProcedure(sql);
if (iMHUtility.IsErrorOnExecution() == false)
{
if (iMHUtility.HasMoreRecords())
{
HasRows = true;
ValueInitialize();
}
}
return HasRows;
}
Also they may create another parameter for sp_name in the method.
|
|
|
|
|
|
Ahh... admittedly, I've been guilty of leaving commented code behind, but they were left behind to work with later. However, I don't think I ever commented copied code like that...
|
|
|
|
|
I'll admit to leaving comments behind when I'm designing new stuff but want to be able to refer to the old stuff, but I only leave it there when I forget or get distracted before finishing the new function.
|
|
|
|
|
Users should left a reason for voting,either it is good or bad. It will make other users to think better in future.I have noticed some users never do it.is it good ? let others users know what is the point that you appreciate or not like.. Thanks to all.
modified on Thursday, March 3, 2011 4:07 PM
|
|
|
|
|
What the heck are you on about?
|
|
|
|
|
|
Monjurul Habib wrote: that is you,5+
Huh?
|
|
|
|
|
|
Hi it's me, the Monthy Python!
|
|
|
|
|
I voted you a 5 what's the point of voting someone a 1 unless you tell them why. Will they learn from their mistake, probably not.
"You get that on the big jobs."
|
|
|
|