|
Developer took special math classes...
|
|
|
|
|
Almost 12 years ago (before I joined the company ), this little beauty almost made it into the release build of one of our applications:
CString strTimeZone;
timeb timeptr;
ftime(&timeptr);
long TimeZone = (long)timeptr.timezone/(long)60;
switch(TimeZone)
{
case 8:
strTimeZone = "P";
break;
case 7:
strTimeZone = "M";
break;
case 6:
strTimeZone = "C";
break;
case 5:
strTimeZone = "E";
break;
default:
AfxMessageBox("Invalid TimeZone. Please Move.");
}
Soren Madsen
|
|
|
|
|
It's not a horror - at least he checked - but it's not that helpful an error message, I must admit. However, it does give advice on how to solve the problem which is a vast improvement on most MS error messages of 12 years ago!
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
You are a true the-glass-is-half-full guy
Soren Madsen
|
|
|
|
|
I think that serves people right for living in invalid timezones!
I'm glad someone was finally willing to tell them
I'm pretty sure the programmer was thinking of timezones such as GMT+4,35 and GMT-27
It's an OO world.
public class Naerling : Lazy<Person>{
public void DoWork(){ throw new NotImplementedException(); }
}
|
|
|
|
|
I wanted to share this, so I actually went to find it in our old SourceSafe database. I deleted a few lines of code that really did nothing, so what you see is what it did.
Today in its place, the code formats a date/time with abbreviated time zone and Daylight saving information - getting the TZ abbreviation right is still a hit and miss (when TZ is outside the US), but at least you don't have to move
Soren Madsen
|
|
|
|
|
SoMad wrote: getting the TZ abbreviation right
You mean something like "MST"?
Simple solution then - there is no deterministic way to solve this because there are time zone abbreviations that are the same for different zones. Best one can do is to
- Use a numeric offset
- Require an environment configuration that matches that offset.
|
|
|
|
|
I recall seeing an error message something like
that a while back.
I thought it was rather stupid, given the fact that
I had just clicked on an item in a drop down list.
I think someone was trying to be funny.
ST
|
|
|
|
|
Well i suppose it wasn't meant to be used outside North America, so it may help avoid the use of illegal copies of that program on China.
|
|
|
|
|
Well, he accounted for EST, not EDT, so I assume for most of the year he got an error for east coast users.
|
|
|
|
|
|
|
I found pretty much the opposite recently...
value = String.Format("Some text here."); That didn't do much good either
It's an OO world.
public class Naerling : Lazy<Person>{
public void DoWork(){ throw new NotImplementedException(); }
}
|
|
|
|
|
I came across many of those in our code years ago from programmers that have since moved on.
The first time I saw it I was thinking "Hmmm. This probably used to have some parameters in it and got modified for some reason". After seeing 5-10 more like that I was just thinking "Hmmm."
Soren Madsen
|
|
|
|
|
Well, I know the programmer who did this in our software.
When asked why he did that he said "I thought that would be useful in case the string ever needed parameters".
He was basically making our software 'future proof'
It's an OO world.
public class Naerling : Lazy<Person>{
public void DoWork(){ throw new NotImplementedException(); }
}
|
|
|
|
|
Did you slap him or punch him in the stomach?
Soren Madsen
|
|
|
|
|
Nope, that would have been very unwise. That guy is my boss!
It's an OO world.
public class Naerling : Lazy<Person>{
public void DoWork(){ throw new NotImplementedException(); }
}
|
|
|
|
|
|
Right. Because adding
String.Format later would be just too hard.
Really, you actually might have to use the arrow keys or the mouse to select in the middle of the line.
In truth, I know someone who would erase and retype the entire line to add something to the middle of it. I am fairly happy to report that he is now out of code and in management instead.
|
|
|
|
|
Would that be 80 proof to match the future whiskey needed to stomach it?
|
|
|
|
|
I've been maintaining a C++ codebase for several years now that has this type of thing all through it:
if (someErrorCondition)
{
char *msg = "Error 404\n";
char s[100];
sprintf(s, "%s", msg);
PrintErrorMessage(s);
}
as opposed to just:
if (someErrorCondition)
PrintErrorMessage("Error 404\n");
And this was in an embedded system, where they were constantly having to eliminate features because they had exceeded the limited code space or overflowed the stack!
|
|
|
|
|
I know the guy who wrote those... Gotta be the same guy....
|
|
|
|
|
Was the code ported from C++?
I haven't seen this one before but definitely seen stuff like this when using a tool to convert from one language to another.
"You get that on the big jobs."
|
|
|
|
|
This was newly written code under an existing ASP.NET C# code base. It was written by a "supposedly" senior developer.
No matter where you go, there you are...~?~
|
|
|
|
|
Tell the original developer to use this
StringBuilder sb = new StringBuilder();
sb.Append(string.empty);
sb.Append(funcThatReturnsAString());
sb.Append(string.empty);
value = sb.ToString();
Tell him this is the standard way of doing this kind of stuff
Every now and then say, "What the Elephant." "What the Elephant" gives you freedom. Freedom brings opportunity. Opportunity makes your future.
|
|
|
|