|
They must have been using the Hafta.net testing framework: Hafta.net.
|
|
|
|
|
There is missing some logic, as assigning sHafta to a member. I hope so...
Greetings from Germany
|
|
|
|
|
I've just read an article that included this little gem
:
if (Convert.ToInt16(chkdate.Length.ToString()) != 11)
{
return false;
} I really don't know where to start (and yes, chkdate is a string).
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Odd that it does "actually" check for 11 characters. I wonder what the code looks like that ensures the "dd/MMM/yyyy" format. There's likely a gem or two in that as well.
|
|
|
|
|
Here[^] you go. Enjoy.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Great. It doesn't validate a thing.
|
|
|
|
|
|
It is now. It was removed because it was so bad and about the best comment against it was that it was complete and utter rubbish.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Pete O`Hanlon wrote: It was removed
It should have been 'An Article of Horror '. It is bad that it was removed and CP deprived many of a viewing pleasure.
|
|
|
|
|
It worries me that we are spiralling into some kind of recursive software hellhole:
void WritePoorCode()
{
bool stuck = true;
if (stuck)
{
GetHelpFromAnotherMuppet();
}
}
void GetHelpFromAnotherMuppet()
{
WritePoorCode();
}
|
|
|
|
|
|
Add tail calls, and it will run forever
xacc.ideIronScheme a R5RS-compliant Scheme on the DLR
The rule of three: "The first time you notice something that might repeat, don't generalize it. The second time the situation occurs, develop in a similar fashion -- possibly even copy/paste -- but don't generalize yet. On the third time, look to generalize the approach."
|
|
|
|
|
Kermit the coder.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
void Main()
{
if (CantAffordAProfessionalDeveloper())
{
CreateACompleteMessOfASystem();
}
}
void CantAffordAProfessionalDeveloper()
{
PayPeanuts();
}
void PayPeanuts()
{
HireSomebodyWithLittleOrNoExperience();
}
void HireSomebodyWithLittleOrNoExperience()
{
if (LearnedFromSchool())
{
GuessCode();
}
if (LearnedFromInternet())
{
GrapSampleFromSomePlace();
}
}
WPF - Imagineers Wanted
Follow your nose using DoubleAnimationUsingPath
|
|
|
|
|
I'm not sure that compiles...
|
|
|
|
|
Try it, you'll be surprised, and even more surprised if we see the same code being used in an Indian offshore system
WPF - Imagineers Wanted
Follow your nose using DoubleAnimationUsingPath
|
|
|
|
|
catch (System.OutOfMemoryException)
{
GetHelpFromAnotherMuppet();
}
Ninja (the Nerd)
Confused? You will be...
|
|
|
|
|
Pete O`Hanlon wrote: Convert.ToInt16(chkdate.Length.ToString()) != 11
why do you rely on an implicit Int16-to-Int32 conversion?
I would recommend an explicit cast to make things more clear.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
That's right. You can't have enough casting and converting going on.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Rediculous .. you need to convert both to decimal to guarentee precision
and get rid of that pesky implicit conversion ...
if(Convert.ToDecimal(Convert.ToInt16(chkdate.Length.ToString())) != Convert.ToDecimal("11")) {
doNoRealValidationCheck_NeverLearnRegex();
}
I'm largely language agnostic
After a while they all bug me
|
|
|
|
|
I think this improves the code a lot… Extra precisions and conversions to make sure we're getting exactly what we want.
((Decimal)Convert.ToDecimal(chkdate.Length.ToString()) != (Decimal)Convert.ToDecimal(((Decimal)(11.0000000000000000000000000000)).ToString())).ToString() == Boolean.TrueString;
The optimizing JITter is going to have fun with this one…
ROFLOLMFAO
|
|
|
|
|
You left out the string.compare call with the ignore case option, and specifying the CultureInfo on the ToString calls.
This blanket smells like ham
|
|
|
|
|
He could've written:
if (Convert.ToChar(chkdate.Length.ToString().ToCharArray()[0]) != new String("1").ToCharArray()[0])
{
if (Convert.ToChar(chkdate.Length.ToString().ToCharArray()[1]) != new String("1").ToCharArray()[0])
{
return false;
}
}
xacc.ideIronScheme a R5RS-compliant Scheme on the DLR
The rule of three: "The first time you notice something that might repeat, don't generalize it. The second time the situation occurs, develop in a similar fashion -- possibly even copy/paste -- but don't generalize yet. On the third time, look to generalize the approach."
|
|
|
|
|
Except you forgot to convert the char types to some int type to ensure it would be a numeric comparison.
|
|
|
|
|
leppie wrote: if (Convert.ToChar(chkdate.Length.ToString().ToCharArray()[0]) != new String("1").ToCharArray()[0]){ if (Convert.ToChar(chkdate.Length.ToString().ToCharArray()[1]) != new String("1").ToCharArray()[0]) { return false; }}
Not so fast, your code does not work while his does.
[Hint] Your code will not return false for strings of length 1, 10, 101, etc.
|
|
|
|