|
Nagy Vilmos wrote: When we came across anything that was [0] of unknown origin or [b] too
embarrassing to admit to, we used one of the SysAdmins' names.
Quite interesting numbering scheme. Was documentation created from the project organized similarily?
The good thing about pessimism is, that you are always either right or pleasently surprised.
|
|
|
|
|
[a] Considering how long you've been and [ii] that you read a lot of forum posts I'd assume you [3] know the convention.
|
|
|
|
|
Or at least at least AT LEAST! do use
{
throw;
}
to prevent slicing of the exception type.
(But maybe that's the purpose: outside code can't handle some Exception-.derived exception)
|
|
|
|
|
That's called the Try-Catch-Throw pattern. It is thoroughly described in
Real World Programming Patterns by W.T. and F.
|
|
|
|
|
Maybe i should have added that this function is actually exported from the dll and used in another dll. The main purpose was reading a xml file.
I don't see any point of using try catch with a throw in the first place and this function isn't safe, because when i use it from the other dll for some trivial job as xml reading I assume that the errors are properly treated in it and I would not use try catch, meaning automatically an crash with invalid xml which i expirienced. For me this function is useless when i can just write that code myself.
Microsoft ... the only place where VARIANT_TRUE != true
|
|
|
|
|
Didn't you see the joke in my post? Look at the author's name of the (non-existing) "book" I quoted. The code snippet you showed us is a WTF, isn't it?
|
|
|
|
|
I am blind, omg I just saw it. Well sarcasm is hard to see in forums sometimes. I am sorry
Microsoft ... the only place where VARIANT_TRUE != true
|
|
|
|
|
Argonia wrote: I don't see any point of using try catch with a throw in the first place
I do. Imagine a pretty red dot on the left margin. Every time this code fails the breakpoint is hit and you can see what exception will be thrown to the rest of the code, especially when it is called from many places.
You can find this in "Real World Programming Patterns", chapter IV: "Abuse of debugger". 
|
|
|
|
|
We don't need no stinking documentation...the code is the documentation.
Code documentation done after the fact is probably worse than having to create a user manual! Even worse is documenting someone else's code!
"Go forth into the source" - Neal Morse
|
|
|
|
|
I clearly remember coming across a comment in the source of an old product called C-Scape.
(That was a common meme back then: C-Scape, C-Front, C-Shell, etc. How I laughed.)
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
Alan Kay.
|
|
|
|
|
I must say I see this exact kind of foolishness pretty often, in the questions at the Q&A forum.
—SASergey A Kryukov
|
|
|
|
|
Just saw this in a colleague's code:
for (int i = 0; i < 2; i++)
{
if (i < 1)
{
}
else if (i > 0)
{
}
}
and a little further down:
for (int i = 0; i < 2; i++)
{
if (i < 1)
{
}
else
}
What is this talk of release? I do not release software. My software escapes leaving a bloody trail of designers and quality assurance people in its wake.
|
|
|
|
|
Has he done some kind of operator overloading and is now laughing at your post?
|
|
|
|
|
And there is no code outside of the if/else construct that runs in both executions of the loop body? Maybe at some time there was such code and it was removed later.
The good thing about pessimism is, that you are always either right or pleasently surprised.
|
|
|
|
|
Maybe. The guy that wrote it told me that he was playing around with the code, testing out a few ideas to deal with a bug. It's quite possible that this weirdness is a leftover of that.
What is this talk of release? I do not release software. My software escapes leaving a bloody trail of designers and quality assurance people in its wake.
|
|
|
|
|
without viewing his full code you cant judge him.. 
|
|
|
|
|
I'm curious, under what circumstances would you find the code the OP posted reasonable?
|
|
|
|
|
Keith Barrow wrote: I'm curious, under what circumstances would you find the code the OP posted reasonable? When the intent of the code is to find itself on Weird-and-Wonderful perhaps? 
|
|
|
|
|
Oh yes, we can
[Flags]
public enum Bool {
True,
False,
ForSure,
Maybe,
ProbablyNot,
Depends,
NotDecidedYet,
Undefined
}
|
|
|
|
|
public static int TenSeconds = 10;
|
|
|
|
|
Maybe it is used as a symbolic constant in various places and the author wanted to be able to change it in just one place. However, in this case the variable name is not the best choice and it should of course be const.
The good thing about pessimism is, that you are always either right or pleasently surprised.
|
|
|
|
|
it is used in exactly one place.
And the uselessness of it is EXACTLY the naming of it.
|
|
|
|
|
Coding standards 1 common sense 0 (this is almost certainly because of a 'no magic numbers' code rule)
|
|
|
|
|
But... that is not a variant of BASIC.. how can bad code be written in a non-BASIC language? Did we experience a shift to an alternate universe?
|
|
|
|
|
Tim Carmichael wrote: how can bad code be written in a non-BASIC language?
You evidently haven't worked the same places I have
worst code I ever saw was in COBOL!
|
|
|
|