Yep I second this statement
bradfoje
@bradfoje
Best posts made by bradfoje
Latest posts made by bradfoje
-
RE: We have automated tests so our code is reliable
Someone else may have explained this already but basically what an Assert() is supposed to be used for is to allow the developer to "Assert" on facts that he knows should be true. If the Assert() fails then it pops up a nasty warning and bombs the program with the stack trace. Asserts only work in code that is compiled in Debug mode, as compiling in Release mode skips them entirely.
An example of this would be
void SomeFunc(object Xy)
{
Assert(Xy != null);
// then do something with Xy
}
Its basically a developers tool. They work the same as exceptions except you can't catch an Assert. The idea is that 99.9% of the time, the Asserts will pass. Basically in the test functions above by them saying Assert(true) is a complete waste of typing and may even be optimized out at compile time. Its like saying if (true == true). The even funnier thing would be if they are compiling these test cases in release mode.
-
RE: Sometimes you should listen
We need an animated GIF of the projectile vomit in her face with the caption of "PWNT"
-
RE: Geek Squad advertizing on TheDailyWTF?!?
Sadly this is a growing trend. I worked with them for 2 years when they first rolled out to WorstBuy. It was an awesome job and people seriously knew what they were doing... for the most part. Then they let managers pick the hires without consulting the lead tech and took the candidates word on "I can hack t3h intarwebz" or "I playz t3h soltarz and win!!" and waaalaaa super timmy techs. Its truely a shame. I enjoyed my time there and did a great job but as time progressed the corporate pigz of WorstBuy got their greedy grubby hands on a great working model and ruined it all to hell.
Thankfully I got me a great software engineering job and probally wouldn't have gotten it without the experience I had when that company actually was competent.
-
RE: Google? Too unreliable.
Without gravity then I'd just attach the rope to the building and jump off the building in the general direction of the message :-) Should be fun.
-
RE: A better way to parse enums
The funny thing about it... it is parsing a field from a file and then passing that entry into the Guess method...
so its taking a string.... comparing that to the first character and if it matches then it returns the enumeration value ToString()... the WTF is that we are limited to a certain number of enumeration values.
So we can't use Between and Both or Boseefus as it will always guess that since it starts with 'B' then it MUST be Between.
-
A better way to parse enums
We all know and love the methods that the .net framework provides for working with enumerations... things like Enum.Parse(), etc etc. While traversing through some of our production code I stumbled across this gem. Its parsing methods far surpass anything that the Enum.Parse() could ever dream of. Knowing the previous developer has a knack for the desire to write his own snippets of code (aka: reinventing the wheel) this came as no surprise:
<FONT color=#008080 size=2><FONT size=2></FONT><FONT color=#0000ff size=2>private</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>string</FONT><FONT size=2> Guess(</FONT><FONT color=#0000ff size=2>string</FONT><FONT size=2> str)
{
</FONT><FONT color=#0000ff size=2> switch</FONT><FONT size=2> (</FONT><FONT color=#0000ff size=2>char</FONT><FONT size=2>.ToUpper(str[0]))</FONT>
<FONT size=2> {</FONT>
<FONT color=#0000ff size=2>c</FONT><FONT color=#0000ff size=2>ase</FONT><FONT size=2> </FONT><FONT color=#800000 size=2>'B'</FONT><FONT size=2>:
</FONT><FONT color=#0000ff size=2>return</FONT><FONT size=2> </FONT><FONT color=#008080 size=2>MyEnum</FONT><FONT size=2>.Between.ToString();
</FONT><FONT color=#0000ff size=2>case</FONT><FONT size=2> </FONT><FONT color=#800000 size=2>'O'</FONT><FONT size=2>:
</FONT><FONT color=#0000ff size=2>return</FONT><FONT size=2> </FONT><FONT color=#008080 size=2>MyEnum</FONT><FONT size=2>.Outside.ToString();
</FONT><FONT color=#0000ff size=2>case</FONT><FONT size=2> </FONT><FONT color=#800000 size=2>'E'</FONT><FONT size=2>:
</FONT><FONT color=#0000ff size=2>return</FONT><FONT size=2> </FONT><FONT color=#008080 size=2>MyEnum</FONT><FONT size=2>.Equal.ToString();
</FONT><FONT color=#0000ff size=2>case</FONT><FONT size=2> </FONT><FONT color=#800000 size=2>'L'</FONT><FONT size=2>:
</FONT><FONT color=#0000ff size=2>return</FONT><FONT size=2> </FONT><FONT color=#008080 size=2>MyEnum</FONT><FONT size=2>.LessThan.ToString();
</FONT><FONT color=#0000ff size=2>case</FONT><FONT size=2> </FONT><FONT color=#800000 size=2>'G'</FONT><FONT size=2>:
</FONT><FONT color=#0000ff size=2>return</FONT><FONT size=2> </FONT><FONT color=#008080 size=2>MyEnum</FONT><FONT size=2>.GreaterThan.ToString();
</FONT><FONT color=#0000ff size=2>default</FONT><FONT size=2>:
</FONT><FONT color=#0000ff size=2>return</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>null</FONT><FONT size=2>;
}
}
</FONT></FONT><FONT size=2></FONT>