I hope this is not contagious...
-
I'm cleaning up other people's mess again and came across this code to validate a date. The comments are from me, as our friend does not believe in comments or any other kind of documentation.
protected void cvaliDatum_ServerValidate(object source, ServerValidateEventArgs args)
{
if (tbDatum.Text.Trim() != "") // useless - parsing an empty string would fail anyway
{
DateTime datok;
if (DateTime.TryParse(tbDatum.Text.Trim(), out datok))
{
if (datok > DateTime.Now) // the date may not be in the future, so this should be <= and not >
{
TimeSpan span = DateTime.Now - datok;
if (span.Days > 14) // the date may not lie back more than 14 days
{
if ((Konstanten.Status == -1) || (Konstanten.Status == 1)) // who knows what that's supposed to mean
{
args.IsValid = false;
}
else
{
args.IsValid = true;
}
}
else
{
args.IsValid = false;
}
}
else
{
args.IsValid = true; // This is plain wrong - should be false }
}
else
{
args.IsValid = false;
}
}
else
{
args.IsValid = false;
}
}As a bonus, the same thing has been copied and pasted to do the validation for another date on the same page. The whole thing just would not be as much fun without some redundancy. Being constantly exposed to this kind of code, I certainly hope that whatever turned the poor author into a moron does not prove itself to be contagious.
At least artificial intelligence already is superior to natural stupidity
-
I'm cleaning up other people's mess again and came across this code to validate a date. The comments are from me, as our friend does not believe in comments or any other kind of documentation.
protected void cvaliDatum_ServerValidate(object source, ServerValidateEventArgs args)
{
if (tbDatum.Text.Trim() != "") // useless - parsing an empty string would fail anyway
{
DateTime datok;
if (DateTime.TryParse(tbDatum.Text.Trim(), out datok))
{
if (datok > DateTime.Now) // the date may not be in the future, so this should be <= and not >
{
TimeSpan span = DateTime.Now - datok;
if (span.Days > 14) // the date may not lie back more than 14 days
{
if ((Konstanten.Status == -1) || (Konstanten.Status == 1)) // who knows what that's supposed to mean
{
args.IsValid = false;
}
else
{
args.IsValid = true;
}
}
else
{
args.IsValid = false;
}
}
else
{
args.IsValid = true; // This is plain wrong - should be false }
}
else
{
args.IsValid = false;
}
}
else
{
args.IsValid = false;
}
}As a bonus, the same thing has been copied and pasted to do the validation for another date on the same page. The whole thing just would not be as much fun without some redundancy. Being constantly exposed to this kind of code, I certainly hope that whatever turned the poor author into a moron does not prove itself to be contagious.
At least artificial intelligence already is superior to natural stupidity
It probably took that contagious to get it working... :-D
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
-
It probably took that contagious to get it working... :-D
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
It never worked and never will. This is just a tiny sample of 9100 equally clueless lines of code in one single ASP .Net webpage. Another one of the coder's specialities is to wrap problematic parts into try blocks, always followed by an empty catch block. It sucessfully pretends that errors never happened and just goes on as if nothing had happened.
At least artificial intelligence already is superior to natural stupidity
-
I'm cleaning up other people's mess again and came across this code to validate a date. The comments are from me, as our friend does not believe in comments or any other kind of documentation.
protected void cvaliDatum_ServerValidate(object source, ServerValidateEventArgs args)
{
if (tbDatum.Text.Trim() != "") // useless - parsing an empty string would fail anyway
{
DateTime datok;
if (DateTime.TryParse(tbDatum.Text.Trim(), out datok))
{
if (datok > DateTime.Now) // the date may not be in the future, so this should be <= and not >
{
TimeSpan span = DateTime.Now - datok;
if (span.Days > 14) // the date may not lie back more than 14 days
{
if ((Konstanten.Status == -1) || (Konstanten.Status == 1)) // who knows what that's supposed to mean
{
args.IsValid = false;
}
else
{
args.IsValid = true;
}
}
else
{
args.IsValid = false;
}
}
else
{
args.IsValid = true; // This is plain wrong - should be false }
}
else
{
args.IsValid = false;
}
}
else
{
args.IsValid = false;
}
}As a bonus, the same thing has been copied and pasted to do the validation for another date on the same page. The whole thing just would not be as much fun without some redundancy. Being constantly exposed to this kind of code, I certainly hope that whatever turned the poor author into a moron does not prove itself to be contagious.
At least artificial intelligence already is superior to natural stupidity
:doh:
void Code(ICodeContext ctx){
throw new BrainNotFoundException();
}
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); } }
}
-
I'm cleaning up other people's mess again and came across this code to validate a date. The comments are from me, as our friend does not believe in comments or any other kind of documentation.
protected void cvaliDatum_ServerValidate(object source, ServerValidateEventArgs args)
{
if (tbDatum.Text.Trim() != "") // useless - parsing an empty string would fail anyway
{
DateTime datok;
if (DateTime.TryParse(tbDatum.Text.Trim(), out datok))
{
if (datok > DateTime.Now) // the date may not be in the future, so this should be <= and not >
{
TimeSpan span = DateTime.Now - datok;
if (span.Days > 14) // the date may not lie back more than 14 days
{
if ((Konstanten.Status == -1) || (Konstanten.Status == 1)) // who knows what that's supposed to mean
{
args.IsValid = false;
}
else
{
args.IsValid = true;
}
}
else
{
args.IsValid = false;
}
}
else
{
args.IsValid = true; // This is plain wrong - should be false }
}
else
{
args.IsValid = false;
}
}
else
{
args.IsValid = false;
}
}As a bonus, the same thing has been copied and pasted to do the validation for another date on the same page. The whole thing just would not be as much fun without some redundancy. Being constantly exposed to this kind of code, I certainly hope that whatever turned the poor author into a moron does not prove itself to be contagious.
At least artificial intelligence already is superior to natural stupidity
-
Beware of the "}" right after comment "// This is plain wrong - should be false" What is Konstanten?
-
I'm cleaning up other people's mess again and came across this code to validate a date. The comments are from me, as our friend does not believe in comments or any other kind of documentation.
protected void cvaliDatum_ServerValidate(object source, ServerValidateEventArgs args)
{
if (tbDatum.Text.Trim() != "") // useless - parsing an empty string would fail anyway
{
DateTime datok;
if (DateTime.TryParse(tbDatum.Text.Trim(), out datok))
{
if (datok > DateTime.Now) // the date may not be in the future, so this should be <= and not >
{
TimeSpan span = DateTime.Now - datok;
if (span.Days > 14) // the date may not lie back more than 14 days
{
if ((Konstanten.Status == -1) || (Konstanten.Status == 1)) // who knows what that's supposed to mean
{
args.IsValid = false;
}
else
{
args.IsValid = true;
}
}
else
{
args.IsValid = false;
}
}
else
{
args.IsValid = true; // This is plain wrong - should be false }
}
else
{
args.IsValid = false;
}
}
else
{
args.IsValid = false;
}
}As a bonus, the same thing has been copied and pasted to do the validation for another date on the same page. The whole thing just would not be as much fun without some redundancy. Being constantly exposed to this kind of code, I certainly hope that whatever turned the poor author into a moron does not prove itself to be contagious.
At least artificial intelligence already is superior to natural stupidity
CDP1802 wrote:
copied and pasted to do the validation for another date
Only such far yet? Things will become much nicer in near future, when a fix is introduced here, another (different) fix there, some extra validation elsewhere, and soon you'll have some ten (different) solutions for the same problem (and none working correctly). Seems to be a wide-spread pattern. Highly contagious, terribly infectious...
-
CDP1802 wrote:
copied and pasted to do the validation for another date
Only such far yet? Things will become much nicer in near future, when a fix is introduced here, another (different) fix there, some extra validation elsewhere, and soon you'll have some ten (different) solutions for the same problem (and none working correctly). Seems to be a wide-spread pattern. Highly contagious, terribly infectious...
This developer is the Dark Lord and master of all techniques that make code unmaintainable. I have the dubious honor of having inherited all projects he ever did. Perhaps I should give him a special award for his lifetime achievements and personally shake his neck.
At least artificial intelligence already is superior to natural stupidity
-
Konstanten is German for Constants. So this seems to be a class with const and readonly properties.
The 'constants' actually are global variables and not constant at all. In web applications he usually (mis)uses the session for this. I can mail you some code if you ever want a scary example of how global variables can lead to an unpredictable mess.
At least artificial intelligence already is superior to natural stupidity
-
Beware of the "}" right after comment "// This is plain wrong - should be false" What is Konstanten?
-
The 'constants' actually are global variables and not constant at all. In web applications he usually (mis)uses the session for this. I can mail you some code if you ever want a scary example of how global variables can lead to an unpredictable mess.
At least artificial intelligence already is superior to natural stupidity
X|
Bill Gates is a very rich man today... and do you want to know why? The answer is one word: versions. Dave Barry Read more at [BrainyQuote](http://www.brainyquote.com/quotes/topics topic_technology.html#yAfSEbrfumitrteO.99)[^]
-
:doh:
void Code(ICodeContext ctx){
throw new BrainNotFoundException();
}
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); } }
}
1.34 in the middle of the night. But I really needed this. :laugh: :laugh: :laugh: Thank you!
"Real men drive manual transmission" - Rajesh.
-
1.34 in the middle of the night. But I really needed this. :laugh: :laugh: :laugh: Thank you!
"Real men drive manual transmission" - Rajesh.
No problem.
Bill Gates is a very rich man today... and do you want to know why? The answer is one word: versions. Dave Barry Read more at [BrainyQuote](http://www.brainyquote.com/quotes/topics topic_technology.html#yAfSEbrfumitrteO.99)[^]