|
+5
|
|
|
|
|
That reminds me of an idea I had at our office - extended validation using a keyword capable of administering mild electric shocks every time a user does something like use a "." in a text field they can't be bothered to fill in.
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
Alan Kay.
|
|
|
|
|
I have a 200kg capable anthropomorphic robot in the basement I can lend it to you, don't hesitate to ask for it, of course given the fact you will allow me to use it before some times...
Please, put a MadSlapMode in the software in which the robot will start slapping everyone at a fast pace without even making a single question.
|
|
|
|
|
Member 9704383 wrote: There were also variables named bob, mike, jane etc.
That's good to write readable code. Bob, short for Robert, meaning: "bright fame". So it's a variable used as a loop counter.
Jane has the meaning of "God is Great" it's used for holding global program-status.
Everybody knows that someone with the name mike drinks to much alcohol. So it's used for error-handling.
The meaning of Jina is "named child", so child-objects are called that way, while root-objects are called adam and an objects that controls other objects is called eve.
If you use those variable-names, everyone knows the meaning.
Author of Primary ROleplaying SysTem
How do I take my coffee? Black as midnight on a moonless night.
War doesn't determine who's right. War determines who's left.
|
|
|
|
|
The best function I had was. It was in VBA, so translated to C#
public void ApriTiQuandoTiDicoIo()
{
...
}
It's Italian for "OpenWhenITellItToYou()", and it did exactly that: Open a File only when I (the developer) wants it.
The signature is in building process.. Please wait...
|
|
|
|
|
Maybe you should smoke tobacco instead of marijuana
|
|
|
|
|
While looking into some production issues and after much looking into the few functions that span over 700-1000 lines, I stumbled upon the root cause. Oh my what a priceless gem!
private static int somefunction(some params)
{
int iKey = -1;
try
{
}
catch (SqlException ex)
{
return iKey;
}
catch (Exception ex)
{
return iKey;
}
finally
{
}
return iKey;
}
|
|
|
|
|
What a 'crazy code' it is...
Compiler shouldn't have allowed return statements in catch
Understand SOLID! Believe SOLID! Try SOLID! Do implement live SOLID; your Code base becomes Rock SOLID!!!
http://www.codeproject.com/Articles/593751/Code-Review-Checklist-and-Guidelines-for-Csharp-De
|
|
|
|
|
Developers who would like to keep their jobs writing production code should have a clue about exception handling.
|
|
|
|
|
I battle against these every day, my sympathies.
|
|
|
|
|
I think he missed "return iKey" in the finally clause
|
|
|
|
|
If it's C#, you can't have a return in a finally clause.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
|
look at the code below:
int main(){
char *c=new char[10];
delete [10,05]c;
return 0;
}
compile fine in visual studio 2008
and error in gcc.
I wish I could believe there is an after life.
|
|
|
|
|
What happens during execution?
|
|
|
|
|
With Visual studio, work fine,
with g++ compilation error
I wish I could believe there is an after life.
|
|
|
|
|
It runs successfully without errors then... Wow!
|
|
|
|
|
This is a (rather pointless) MS extension to C++: Pointless extension[^]
In your case, the comma operator will just throw away so the 10, so it becomes:
delete [05] c;
(Where 05 is an octal number)
And in fact will be ignored, rendering the result exactly the same as:
delete [] c;
"Ours not to reason why".
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
Alan Kay.
|
|
|
|
|
Sh** I remember that ','
I school days, first curse in all year using Visual C++... beautiful monitors of 14" at 1024*768...
We were calculating taxes for students based on Age and grade...
There were some students that were paying always 0.00 ... we debug (we were students, still stupids at debuging)... noting show wrong...
After like 5 hours... I went to play Ping Ping.. I returned, found my 2 teammates debugging.. then I notices and ask:
Guys is that payment * 0.05 or payment * 0,05... I learned that day that VC++ when 0,05 does Payment * 0 * 05.. then everything become 0!!!!
|
|
|
|
|
Let me start this discussion something like this:
Obviously, we need to catch only specific exceptions and that too if it is required.
But unfortunately this is not the case in my company. Here for each and every method (regardless it is required or not) you will find a single catch catching only the top Exception. Error logging is being done here and then sometimes it is being rethrown.
I dont understand this scheme/practice and hence I discussed regarding it with my Developers, peers, and Manager(s) but most of them say something like these:
--> 'It does not make any difference'
--> 'We are doing in this same fashion everywhere from beginning'
--> 'My TL asked me to follow like this'
--> 'It is a client's requirement to log all top exceptions all times and it should not be missed anytime'
Is any point from above is applicable?
Let's have some discussion please so that I get a broad and clear picture.
Thanks.
Understand SOLID! Believe SOLID! Try SOLID! Do implement live SOLID; your Code base becomes Rock SOLID!!!
http://www.codeproject.com/Articles/593751/Code-Review-Checklist-and-Guidelines-for-Csharp-De
|
|
|
|
|
Doesn't that go against the whole point of exception handling? try/catch is not equivalent of VB's On Error Goto.
Also if the code breaks all the time then its hardly an 'exception' is it?
And debugging must be a pain, as VS will break in catch block, not where the error occurred wont it?
How many of these catch blocks are entered on regular operation? Exceptions aren't cheap to throw after all.
Also is a try/catch block 'free' of any performance/memory penalty?
|
|
|
|
|
You raised very valid points. Thanks.
Understand SOLID! Believe SOLID! Try SOLID! Do implement live SOLID; your Code base becomes Rock SOLID!!!
http://www.codeproject.com/Articles/593751/Code-Review-Checklist-and-Guidelines-for-Csharp-De
|
|
|
|
|
cjb110 wrote: Also is a try/catch block 'free' of any performance/memory penalty?
It should be, certainly is in C++, and I'd imagine most later languages have been sensible enough to copy that implementation. Throwing exceptions has a definite overhead, but probably no more than writing the error code manually.
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
Alan Kay.
|
|
|
|
|
The question is why do you catch exceptions at all...
Most common answer is - to react to specific errors, for example - AccessDenied exception -> show message to user, SQLException - inform about DB problems or retry/abort and clean up..., etc.
In theory if application is properly writen, nothing unexpected should happen. But what if it happens?
You have two options:
1. Allow you OS/Framework show "unhandled exception" message - this annoys end users and makes troubleshooting harder as most users will close the window and will not report the details
2. Catch all otherwise unhandled exceptions and do something with them - log and rethrow or supress with generic error message and app shutdown/restart
Generally in development - this is not very good, unless you have a breakpoint in catch block or rethrow exception in debug config.
In production - I personally think this is good idea. For sure better than "unhandled exception" or empty catch block.
|
|
|
|
|
That's a nice explanation Jarek!!! Thanks.
So you mean you support placing try/catch blocks everywhere and catching the main Exception everywhere, right? (But I'm still not supporting this practice) .
As you said, if it is properly written then no exceptions at all. But yes this is not the case always for some exceptions like MemoryOverflow, AccessDenied, etc. Therefore for only these kind of exceptions might specifically catch them.
Understand SOLID! Believe SOLID! Try SOLID! Do implement live SOLID; your Code base becomes Rock SOLID!!!
http://www.codeproject.com/Articles/593751/Code-Review-Checklist-and-Guidelines-for-Csharp-De
|
|
|
|