Why String.Format?
-
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." :omg: 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' :laugh:
It's an OO world.
public class Naerling : Lazy<Person>{
public void DoWork(){ throw new NotImplementedException(); }
} -
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' :laugh:
It's an OO world.
public class Naerling : Lazy<Person>{
public void DoWork(){ throw new NotImplementedException(); }
} -
Nope, that would have been very unwise. That guy is my boss! :laugh:
It's an OO world.
public class Naerling : Lazy<Person>{
public void DoWork(){ throw new NotImplementedException(); }
} -
Just ran across some code today that makes me wonder about the caliber of programmers we have: value = String.Format("{0}", funcThatReturnsAString()); :confused::confused::confused::confused:
No matter where you go, there you are...~?~
-
Nope, that would have been very unwise. That guy is my boss! :laugh:
It's an OO world.
public class Naerling : Lazy<Person>{
public void DoWork(){ throw new NotImplementedException(); }
}Thing about this code is it was written very recently and by a so called senior developer.:confused::confused::confused:
No matter where you go, there you are...~?~
-
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. :confused:
No matter where you go, there you are...~?~
-
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' :laugh:
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.
-
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' :laugh:
It's an OO world.
public class Naerling : Lazy<Person>{
public void DoWork(){ throw new NotImplementedException(); }
} -
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....
-
Just ran across some code today that makes me wonder about the caliber of programmers we have: value = String.Format("{0}", funcThatReturnsAString()); :confused::confused::confused::confused:
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 :laugh:
Every now and then say, "What the Elephant." "What the Elephant" gives you freedom. Freedom brings opportunity. Opportunity makes your future.