|
That has to be him!
public class SysAdmin : Employee
{
public override void DoWork(IWorkItem workItem)
{
if (workItem.User.Type == UserType.NoLearn){
throw new NoIWillNotFixYourComputerException(new Luser(workItem.User));
}else{
base.DoWork(workItem);
}
}
}
|
|
|
|
|
This is just as bad as my example of String.Format.
No matter where you go, there you are...~?~
|
|
|
|
|
If you've read anything about strings, you must have read that you should use StringBuilder instead. "some text" + "some more" + " text" is expensive. I would guess Concat gives you a performance boost similar to StringBuilder, but limited to strings. I have to admit that appending each value individually in builder is bothersome.
I know I wanted to find out how much builder helps, so I built a cpu intensive process with accounting numbers. I mixed fixed text with numbers to a string using + logic. Got the actual coding to work and changed over to StringBuilder. Processing went from 40 minutes to 20 minutes. Then I changed the logic to only use builder when I needed to save the stat strings. Cut down to 7 minutes. Then played with the process order and it went to 4 minutes. Needed to buy my second laptop in 7 years to cut it to 2 minutes.
|
|
|
|
|
Would someone do this:
public IEnumerable<TrackingTagSpan<T>> GetTaggedSpans(SnapshotSpan span)
{
IList<TrackingTagSpan<T>> source = new List<TrackingTagSpan<T>>(this._trackingTagSpans);
lock (this.mutex)
{
source = new List<TrackingTagSpan<T>>(this._trackingTagSpans);
}
return
from tagSpan in source
where span.IntersectsWith(tagSpan.Span.GetSpan(span.Snapshot))
select tagSpan;
}
This is from a builtin class (SimpleTagger<T> ) in the Visual Studio SDK.
Edit: Looks like I upset a Microsoftie. Instead of downvoting, go fix the f#@kin crap code buddy.
modified 14-Jun-12 7:56am.
|
|
|
|
|
This guy had his head full of coffee (or other drugs, can't say exactly)
Maybe the code where longer before and was shortened to this
I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p)
|
|
|
|
|
Would a simple error be a ground-breaking concept for you?
|
|
|
|
|
Vitaly Tomilov wrote: Would a simple error be a ground-breaking concept for you?
What is that suppose to mean?
|
|
|
|
|
Looks like a simple error, which needs a simple fix.
|
|
|
|
|
Vitaly Tomilov wrote: Looks like a simple error, which needs a simple fix.
Firstly, simple error yes, but why is this not spotted a mile away?
Secondly, this is not my code. It is Microsoft's production code, that lives in VS2010 and VS2012. It is up to them to fix such a simple error.
|
|
|
|
|
I found 100+ StringBuilder s in a module(see below).
function string function1()
{
System.Text.StringBuilder sb1 = new System.Text.StringBuilder();
....
...
}
function void method1()
{
System.Text.StringBuilder sb2 = new System.Text.StringBuilder();
....
...
}
function string function3()
{
System.Text.StringBuilder sb3 = new System.Text.StringBuilder();
....
...
}
....
...
Then I have Included the namespace at top of the module.
using System.Text;
And replaced System.Text.StringBuilder with StringBuilder
thatrajaNobody remains a virgin, Life screws everyone
|
|
|
|
|
This isn't like a hidden bug or the things we usually see over here...
I think CP has some people that maybe like that style...
I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p)
|
|
|
|
|
Just a little reminder: This is the "Hall Of Shame" and not he "Hall Of Bugs". There is no good reason to clutter ones code with superflous repetitions of the namespace prefixing the StringBuilder, except maybe when there is another implementation of StringBuilder floating around.
Just my two cents!
"With sufficient thrust, pigs fly just fine."
Ross Callon, The Twelve Networking Truths, RFC1925
|
|
|
|
|
I don't see the shame on this, this guy just like to write long names
I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p)
|
|
|
|
|
|
I was talking about the original programmer, is that you?
I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p)
|
|
|
|
|
Sentenryu wrote: I was talking about the original programmer, is that you? No
thatrajaNobody remains a virgin, Life screws everyone
|
|
|
|
|
That's not "style", but a "preference"; the difference is that one needs arguments, the other doesn't. People who prefer the long naming should try prefixing everything with "global::".
Bastard Programmer from Hell
|
|
|
|
|
Personally, I always import, unless there is already something with the same name imported.
But it's a matter of taste.
I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p)
|
|
|
|
|
Sentenryu wrote: I always import
But that's not what the using directive does. There is no "import" in C# -- the closest to that is references.
|
|
|
|
|
my teachers always said import here in Brazil, I ended up picking up the habit...
I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p)
|
|
|
|
|
Sentenryu wrote: But it's a matter of taste.
No, it's not.
Bloating code is an offence. Three offences, you're out.
Bastard Programmer from Hell
|
|
|
|
|
But, some folk like to bloat their code.
I agree, there is no good reason to do this, but it is not as bad as wacky, buggy code.
Just because the code works, it doesn't mean that it is good code.
|
|
|
|
|
CIDev wrote: I agree, there is no good reason to do this, but it is not as bad as wacky, buggy code.
To quote one of the arguments why it is;
CIDev wrote: Just because the code works, it doesn't mean that it is good code.
And that's easy to explain; the more symbols you need to convey an idea, the more chances that there's an error in the communication. The more symbols, the more fluff, the more bugs.
Bastard Programmer from Hell
|
|
|
|
|
Eddy Vluggen wrote: prefixing everything with "global::".
I tried that, briefly.
|
|
|
|
|
PIEBALDconsult wrote: I tried that, briefly.
..a good idea, if you are paid per line written.
It should feel comparably to explicitly stating that a member is "private", and prefixing everything possible with "this".
Bastard Programmer from Hell
|
|
|
|