|
|
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.
|
|
|
|
|
Of course not ! Thats an exercise for the next poor soul that works on the code :p
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."
|
|
|
|
|
Pete O`Hanlon wrote: ://it checks it contains 11 char (dd/MMM/yyyy)
if (Convert.ToInt16(chkdate.Length.ToString()).ToString() != "11")
{
//if it does not have 11 char then it will return false
return false;
}
Fixed
|
|
|
|
|
Is this what they call optimized code?
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->ßRÅhmmÃ<-·´¯`·.
|
|
|
|
|
For checking whether the string contains a valid date the code is crap. (SCNR)
This shows what the results of "high level" programming languages are.
Greetings from Germany
|
|
|
|
|
KarstenK wrote: This shows what the results of "high level" programming languages are
Idiot developers who shouldn't be let anywhere near a keyboard without being wired up to the mains and given a shock everytime they produce crap like this.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Then even the lead developer would be shocking.
Ninja (the Nerd)
Confused? You will be...
|
|
|
|