|
Sadly, I've written code like that.
Marc
|
|
|
|
|
Yes, but you only do it once, and then when you realize your blunder, you promise yourself to never go there again. Right?
--
Kein Mitleid Für Die Mehrheit
|
|
|
|
|
Jörgen Sigvardsson wrote: , you promise yourself to never go there again. Right?
Exactly. And generalizing the blunder, you realize how evil "if" statements actually are and carefully consider the use of them!
Marc
|
|
|
|
|
I stopped using branches years ago. It's my way or the highway!
--
Kein Mitleid Für Die Mehrheit
|
|
|
|
|
Remembers me to some date comparisons I have done with plain C - long ago
(but mine were at least correct )
I was very happy when I had to do it the first time with C# and found out I can do it like this:
DateTime dtPast = new DateTime(2009, 9, 9);
DateTime dtNow = new DateTime(2010, 10, 10);
DateTime dtFuture = new DateTime(2011, 11, 11);
bool bIsBetween = dtNow > dtPast && dtNow < dtFuture;
|
|
|
|
|
So I was looking at some code I wrote a few years back, when I was first learning objective-C. I found many places where I did something like this:
char buffer[100];
sprintf(buffer, "the value: %d", someValue);
NSString* string = [NSString stringWithCString:buffer];
of course, with more useful text and values. I think there may have even been some times when I malloc'd buffer rather than having it on the stack... for those who aren't familiar with obj-C, this could be more sanely/appropriately written as:
NSString* string = [NSString stringWithFormat:"the value: %d", someValue"];
|
|
|
|
|
I constantly observe the same type of constructions with the MFC CString, when the programer does not realize there is a .Format() function to do the same thing.
I also crack up at the use of strlen and its variants to detect if the string is empty. How about just chekcing the first array slot for a zero! Or maybe they weren't after any kind of performance after all...
|
|
|
|
|
I have known programmers who say that readability is more important than small performance gains. This doesn’t sound too bad until you realize that by “readable” they mean “using what they are familiar with” and not learning new, faster and better ways of doing things. Also the performance of their code is abysmal.
Just because the code works, it doesn't mean that it is good code.
|
|
|
|
|
The real horror here is that you don't check for the possibility of buffer overrun.
|
|
|
|
|
I found this jewel in my company's codebase
check the name of the Enum on the second line
szError = PrnError.GetLoadImgError(iflRet);
Done(szError, ModusOperandi.ImageErrorMgr);
|
|
|
|
|
This is what happens when lawyers become programmers )
P.S. Once a musician saw my C# book and asked me "Why is this thick book called Do-Diese?"
|
|
|
|
|
|
As Modus Operandi means, literally, "Method of Operating", I can see that applying as a valid (if unusual) name in many situations.
Unfortunately not this one, I guess that should be Modus Non Operandi.
So I guess that remains a horror.
|
|
|
|
|
Rob Grainger wrote: Unfortunately not this one, I guess that should be Modus Non Operandi.
So I guess that remains a horror.
So, in an interview for a programming job when asked what languages he knows, the correct answer would be..."I've used Latin, but I'm no expert".
-Rd
|
|
|
|
|
Richard A. Dalton wrote: So, in an interview for a programming job when asked what languages he knows, the correct answer would be..."I've used Latin, but I'm no expert".
And if I were the interviewer, I would extend my hand to the prospect and say with a smile: Noli me vocare. Ego te vocabo.
|
|
|
|
|
if (lang == "Japanese")
{
msg.BodyEncoding = System.Text.Encoding.UTF8;
msg.SubjectEncoding = System.Text.Encoding.UTF8;
}
else
{
msg.BodyEncoding = System.Text.Encoding.UTF8;
msg.SubjectEncoding = System.Text.Encoding.UTF8;
}
R A M
|
|
|
|
|
I found this some one posted in ASP.NET questions today, What could be the possible reason to set same encoding with conditional statement?
R A M
|
|
|
|
|
MalikRizwan wrote: What could be the possible reason to set same encoding with conditional statement?
Step 1 - Copy
Step 2 - Paste
Step 3 - .... Oohh Donuts
It could be a simple case of "I'll get back to that"
I was debugging some code a few years back, there was a strange error where the system just bombed out under certain circumstances. Error handling was otherwise very good.
I finally traced the problem to a function that was literally half written. It was like the developer just stopped mid thought and never got back to it.
It was syntactically correct, but it made little sense beyond that.
I couldn't for the life of my figure out what had posessed the developer until I noticed that he had entered a comment at the head of the function.
The date of the comment was 11-Sep-2001.
He, like everyone else had dropped everything and run to the TV, and never got back to what he was doing.
-Rd
|
|
|
|
|
|
There was this guy who joined our team as a trainee. Who, according to him, had enough knowledge of .NET specially exception handling..later on i found his code full of TRY CATCH literally on each line .. something like this..
int budgetAmount =0;
try
{
budgetAmount = 10;
}catch(Exception ex)
{
}
try
{
if(budgetAmount==10)
budgetAmount += (baselineAmount * actualAmount);
}catch(Exception ex)
{
}
and so on
R A M
|
|
|
|
|
I am now going to cry in a corner.
I wonder what proportion of successful programmers are self-taught? Just a hunch...
Posted from SPARTA!!!!!!!!!! 2.0.
Don't forget to rate my post if it helped!
|
|
|
|
|
Self-taught?? Isn't taught pushing it a bit....
|
|
|
|
|
I dunno. I wouldn't be surprised if a larger percentage of great programmers were self-taught. Shows initiative/care for the topic.
Posted from SPARTA!!!!!!!!!! 2.0.
Don't forget to rate my post if it helped!
|
|
|
|
|
If you don't ever learn a little something on your own, you'll never be a great programmer.
|
|
|
|
|
Yeah, still can't get over the copypasta 'programmers'.
Posted from SPARTA!!!!!!!!!! 2.0.
Don't forget to rate my post if it helped!
|
|
|
|