Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. I hope this is not contagious...

I hope this is not contagious...

Scheduled Pinned Locked Moved The Weird and The Wonderful
json
13 Posts 7 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Lost User

    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

    B Offline
    B Offline
    Brisingr Aerowing
    wrote on last edited by
    #4

    :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);
          }
     }
    

    }

    R 1 Reply Last reply
    0
    • L Lost User

      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 Offline
      I Offline
      ignrod
      wrote on last edited by
      #5

      Beware of the "}" right after comment "// This is plain wrong - should be false" What is Konstanten?

      D L 2 Replies Last reply
      0
      • I ignrod

        Beware of the "}" right after comment "// This is plain wrong - should be false" What is Konstanten?

        D Offline
        D Offline
        dakovinc
        wrote on last edited by
        #6

        Konstanten is German for Constants. So this seems to be a class with const and readonly properties.

        L 1 Reply Last reply
        0
        • L Lost User

          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

          B Offline
          B Offline
          Bernhard Hiller
          wrote on last edited by
          #7

          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...

          L 1 Reply Last reply
          0
          • B Bernhard Hiller

            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...

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #8

            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

            1 Reply Last reply
            0
            • D dakovinc

              Konstanten is German for Constants. So this seems to be a class with const and readonly properties.

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #9

              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

              B 1 Reply Last reply
              0
              • I ignrod

                Beware of the "}" right after comment "// This is plain wrong - should be false" What is Konstanten?

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #10

                Sorry, that must have been me when formatting the code.

                At least artificial intelligence already is superior to natural stupidity

                1 Reply Last reply
                0
                • L Lost User

                  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

                  B Offline
                  B Offline
                  Brisingr Aerowing
                  wrote on last edited by
                  #11

                  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)[^]

                  1 Reply Last reply
                  0
                  • B Brisingr Aerowing

                    :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);
                          }
                     }
                    

                    }

                    R Offline
                    R Offline
                    Rajesh R Subramanian
                    wrote on last edited by
                    #12

                    1.34 in the middle of the night. But I really needed this. :laugh: :laugh: :laugh: Thank you!

                    "Real men drive manual transmission" - Rajesh.

                    B 1 Reply Last reply
                    0
                    • R Rajesh R Subramanian

                      1.34 in the middle of the night. But I really needed this. :laugh: :laugh: :laugh: Thank you!

                      "Real men drive manual transmission" - Rajesh.

                      B Offline
                      B Offline
                      Brisingr Aerowing
                      wrote on last edited by
                      #13

                      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)[^]

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups