Now this is embarassing
-
Nothing against them except perchance in, humm, let's say orally challenging situations. ;P
"I had the right to remain silent, but I didn't have the ability!"
Ron White, Comedian
-
if (_Uptime != null)
{
_Uptime.Remove(TraCommon.Tokens.TraService_Speed);
}
{
_Uptime = new Service.Message();
_Uptime.Code = SysCommon.CommandCode.SysUptimeEvt;
}I just found this in my code. It's been there for years.
Software Zen:
delete this;
Add this comment before anyone notice your code!
// This embarrassing code is definitely not written by Gary Wheeler!
if (_Uptime != null)
{
_Uptime.Remove(TraCommon.Tokens.TraService_Speed);
}
{
_Uptime = new Service.Message();
_Uptime.Code = SysCommon.CommandCode.SysUptimeEvt;
}:laugh:
-
Add this comment before anyone notice your code!
// This embarrassing code is definitely not written by Gary Wheeler!
if (_Uptime != null)
{
_Uptime.Remove(TraCommon.Tokens.TraService_Speed);
}
{
_Uptime = new Service.Message();
_Uptime.Code = SysCommon.CommandCode.SysUptimeEvt;
}:laugh:
-
if (_Uptime != null)
{
_Uptime.Remove(TraCommon.Tokens.TraService_Speed);
}
{
_Uptime = new Service.Message();
_Uptime.Code = SysCommon.CommandCode.SysUptimeEvt;
}I just found this in my code. It's been there for years.
Software Zen:
delete this;
Don't be too embarassed. It's quite normal[^]
-
if (_Uptime != null)
{
_Uptime.Remove(TraCommon.Tokens.TraService_Speed);
}
{
_Uptime = new Service.Message();
_Uptime.Code = SysCommon.CommandCode.SysUptimeEvt;
}I just found this in my code. It's been there for years.
Software Zen:
delete this;
At the risk of starting a slashdot-style flame war I refuse to code an if without:
if (condition) {
consequence;
} else {
negative consequence;
}Can't help it. Can't change it. 56 years old and too old to recover from it. But also pretty hard to miss an 'else'. Please don't hate me...
-
At the risk of starting a slashdot-style flame war I refuse to code an if without:
if (condition) {
consequence;
} else {
negative consequence;
}Can't help it. Can't change it. 56 years old and too old to recover from it. But also pretty hard to miss an 'else'. Please don't hate me...
Part of my problem is that, due to changes in style guidelines in my group over time, I have a body of older code that uses K&R braces. My newer stuff, including the aforementioned C#, uses the brace-per-line style.
Software Zen:
delete this;
-
if (_Uptime != null)
{
_Uptime.Remove(TraCommon.Tokens.TraService_Speed);
}
{
_Uptime = new Service.Message();
_Uptime.Code = SysCommon.CommandCode.SysUptimeEvt;
}I just found this in my code. It's been there for years.
Software Zen:
delete this;
Gary Wheeler wrote:
It's been there for years.
Then it has been working for years too! Don't fix it!
To alcohol! The cause of, and solution to, all of life's problems - Homer Simpson ---- Our heads are round so our thoughts can change direction - Francis Picabia
-
Gary Wheeler wrote:
Mine was a sin of omission, while his was a sin of emission.
Someone mentioned in the other link that an empty statement shouldn't be allowed after an if statement. I think both should be allowed, but have warning messages. His would be "The conditional statement won't execute anything", yours "Extra brackets added for no apparent reason". Both may be a stretch for the compiler to see. On the other hand, people who like padded coding might not like that.
-
-
if (_Uptime != null)
{
_Uptime.Remove(TraCommon.Tokens.TraService_Speed);
}
{
_Uptime = new Service.Message();
_Uptime.Code = SysCommon.CommandCode.SysUptimeEvt;
}I just found this in my code. It's been there for years.
Software Zen:
delete this;
This reminds me why i hate ppl who write code like if (x != y) doThis(); remember one time when somebody added some code --> if (x != y) doThis(); alsoDoThat(); Took a while in debugger to figure out what was reason :-p Cause not part of my code :-) I always write my code after that if (x != y) { doThis(); } Even if have to do only one thing :-p
-
missing else? Don't you just love scoping braces.
Software Kinetics - Dependable Software news
I did this once in c++, took very long to figure out:
if (condition);
{}
____________________________________________________________ Be brave little warrior, be VERY brave
-
if (_Uptime != null)
{
_Uptime.Remove(TraCommon.Tokens.TraService_Speed);
}
{
_Uptime = new Service.Message();
_Uptime.Code = SysCommon.CommandCode.SysUptimeEvt;
}I just found this in my code. It's been there for years.
Software Zen:
delete this;
Would have been obvious in VB.NET.
-
Would have been obvious in VB.NET.
Every line of code in VB.Net is obviously a mistake. ;P
-
I did this once in c++, took very long to figure out:
if (condition);
{}
____________________________________________________________ Be brave little warrior, be VERY brave
-
I'd be more concerned if there was something between the braces to get unexpectedly executed irrespective of the intended condition.
That's exactly what happened, irrespective of the condition the code block always executed...
____________________________________________________________ Be brave little warrior, be VERY brave
-
I did this once in c++, took very long to figure out:
if (condition);
{}
____________________________________________________________ Be brave little warrior, be VERY brave
And I did this once in C, also took me long to figure it out: for (i=0; i <= ....; i ++); { }
-
Embarassing2A: We use SourceSafe. Embarassing2B: It would still tell you that it really is.
Software Zen:
delete this;
-
This reminds me why i hate ppl who write code like if (x != y) doThis(); remember one time when somebody added some code --> if (x != y) doThis(); alsoDoThat(); Took a while in debugger to figure out what was reason :-p Cause not part of my code :-) I always write my code after that if (x != y) { doThis(); } Even if have to do only one thing :-p
That's usually the case for me as well.
Software Zen:
delete this;
-
Gary Wheeler wrote:
It's been there for years.
Then it has been working for years too! Don't fix it!
To alcohol! The cause of, and solution to, all of life's problems - Homer Simpson ---- Our heads are round so our thoughts can change direction - Francis Picabia
Actually, it's not. In the code you don't see, it ends up replacing existing information when it should be adding it. The existing information gets lost.
Software Zen:
delete this;
-
Actually, it's not. In the code you don't see, it ends up replacing existing information when it should be adding it. The existing information gets lost.
Software Zen:
delete this;
I did notice that. What I meant is that the application was obviously working for years with that code, unless it's been abandoned. If it was behaving incorrectly it would've been noticed before. I'm not saying that what the code was doing was correct, just that the application was behaving as expected.
To alcohol! The cause of, and solution to, all of life's problems - Homer Simpson ---- Our heads are round so our thoughts can change direction - Francis Picabia