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. You're already late

You're already late

Scheduled Pinned Locked Moved The Weird and The Wonderful
databasedesign
9 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.
  • F Offline
    F Offline
    Fernando Padoan
    wrote on last edited by
    #1

    Last week, I was asked to change an old tasks report, adding a parameter for the completion status of a task. As it was my first task on this feature, I have been advised by the project's analyst that the report was showing only the overdue tasks. As I moved to find and change the hardcoded status to the one selected on the UI, I've seen a call to a static method Status TaskStatus.GetEnum(), which would translate the selected option to the corresponding value from a Status enum (ok, I know, it sounds obvious). Actually, it was already being applied to the report, but the query was ignoring the status parameter anyway. Then I decided to look into that method, and found this:

    public class TaskStatus
    {
        public enum Status
        {
            OVERDUE,
            CLOSED,
            ON\_TIME
        }
        public static Status GetEnum(string name)
        {
            switch (name)
            {
                case "":
                    return Status.OVERDUE;
                default:
                    return Status.OVERDUE;
            }
        }
    }
    

    Update: added some context.

    modified on Thursday, August 26, 2010 11:38 PM

    P R B D 4 Replies Last reply
    0
    • F Fernando Padoan

      Last week, I was asked to change an old tasks report, adding a parameter for the completion status of a task. As it was my first task on this feature, I have been advised by the project's analyst that the report was showing only the overdue tasks. As I moved to find and change the hardcoded status to the one selected on the UI, I've seen a call to a static method Status TaskStatus.GetEnum(), which would translate the selected option to the corresponding value from a Status enum (ok, I know, it sounds obvious). Actually, it was already being applied to the report, but the query was ignoring the status parameter anyway. Then I decided to look into that method, and found this:

      public class TaskStatus
      {
          public enum Status
          {
              OVERDUE,
              CLOSED,
              ON\_TIME
          }
          public static Status GetEnum(string name)
          {
              switch (name)
              {
                  case "":
                      return Status.OVERDUE;
                  default:
                      return Status.OVERDUE;
              }
          }
      }
      

      Update: added some context.

      modified on Thursday, August 26, 2010 11:38 PM

      P Offline
      P Offline
      Philip F
      wrote on last edited by
      #2

      Looks like the programmer had the specific requirement to increase productivity of task report users ;) This would have been worse ;)

      switch(name)
      {
      case "":
      return Status.ON_TIME;
      default:
      return Status.ON_TIME;
      }

      I won’t not use no double negatives.

      1 Reply Last reply
      0
      • F Fernando Padoan

        Last week, I was asked to change an old tasks report, adding a parameter for the completion status of a task. As it was my first task on this feature, I have been advised by the project's analyst that the report was showing only the overdue tasks. As I moved to find and change the hardcoded status to the one selected on the UI, I've seen a call to a static method Status TaskStatus.GetEnum(), which would translate the selected option to the corresponding value from a Status enum (ok, I know, it sounds obvious). Actually, it was already being applied to the report, but the query was ignoring the status parameter anyway. Then I decided to look into that method, and found this:

        public class TaskStatus
        {
            public enum Status
            {
                OVERDUE,
                CLOSED,
                ON\_TIME
            }
            public static Status GetEnum(string name)
            {
                switch (name)
                {
                    case "":
                        return Status.OVERDUE;
                    default:
                        return Status.OVERDUE;
                }
            }
        }
        

        Update: added some context.

        modified on Thursday, August 26, 2010 11:38 PM

        R Offline
        R Offline
        Richard A Dalton
        wrote on last edited by
        #3

        There could be a seperate section for Coding Doh's :doh: The difference between a Coding Horror and a Coding Doh! is subtle. Both involve the desire to slap a programmer in the head. With a Coding Doh! the programmer wants to slap themselves, with a Coding Horror another programmer feels the urge to administer the slap.

        F P 2 Replies Last reply
        0
        • R Richard A Dalton

          There could be a seperate section for Coding Doh's :doh: The difference between a Coding Horror and a Coding Doh! is subtle. Both involve the desire to slap a programmer in the head. With a Coding Doh! the programmer wants to slap themselves, with a Coding Horror another programmer feels the urge to administer the slap.

          F Offline
          F Offline
          Fernando Padoan
          wrote on last edited by
          #4

          Unfortunately, I think the programmer didn't remember to slap himself...

          1 Reply Last reply
          0
          • F Fernando Padoan

            Last week, I was asked to change an old tasks report, adding a parameter for the completion status of a task. As it was my first task on this feature, I have been advised by the project's analyst that the report was showing only the overdue tasks. As I moved to find and change the hardcoded status to the one selected on the UI, I've seen a call to a static method Status TaskStatus.GetEnum(), which would translate the selected option to the corresponding value from a Status enum (ok, I know, it sounds obvious). Actually, it was already being applied to the report, but the query was ignoring the status parameter anyway. Then I decided to look into that method, and found this:

            public class TaskStatus
            {
                public enum Status
                {
                    OVERDUE,
                    CLOSED,
                    ON\_TIME
                }
                public static Status GetEnum(string name)
                {
                    switch (name)
                    {
                        case "":
                            return Status.OVERDUE;
                        default:
                            return Status.OVERDUE;
                    }
                }
            }
            

            Update: added some context.

            modified on Thursday, August 26, 2010 11:38 PM

            B Offline
            B Offline
            BillW33
            wrote on last edited by
            #5

            I would assume that the original coder never got around to finishing the GetEnum method. I sincerely hope that no coder would think that this code would actually work! :~

            Just because the code works, it doesn't mean that it is good code.

            1 Reply Last reply
            0
            • F Fernando Padoan

              Last week, I was asked to change an old tasks report, adding a parameter for the completion status of a task. As it was my first task on this feature, I have been advised by the project's analyst that the report was showing only the overdue tasks. As I moved to find and change the hardcoded status to the one selected on the UI, I've seen a call to a static method Status TaskStatus.GetEnum(), which would translate the selected option to the corresponding value from a Status enum (ok, I know, it sounds obvious). Actually, it was already being applied to the report, but the query was ignoring the status parameter anyway. Then I decided to look into that method, and found this:

              public class TaskStatus
              {
                  public enum Status
                  {
                      OVERDUE,
                      CLOSED,
                      ON\_TIME
                  }
                  public static Status GetEnum(string name)
                  {
                      switch (name)
                      {
                          case "":
                              return Status.OVERDUE;
                          default:
                              return Status.OVERDUE;
                      }
                  }
              }
              

              Update: added some context.

              modified on Thursday, August 26, 2010 11:38 PM

              D Offline
              D Offline
              Dr Walt Fair PE
              wrote on last edited by
              #6

              Well, I can see how that could happen. You code up a switch statement with one case and a default, then get interrupted by something. By the time you get back to coding, you forgot about that and no one complained, so ... Not that it ever happened to me, mind you. :^) :wtf:

              CQ de W5ALT

              Walt Fair, Jr., P. E. Comport Computing Specializing in Technical Engineering Software

              F M 2 Replies Last reply
              0
              • D Dr Walt Fair PE

                Well, I can see how that could happen. You code up a switch statement with one case and a default, then get interrupted by something. By the time you get back to coding, you forgot about that and no one complained, so ... Not that it ever happened to me, mind you. :^) :wtf:

                CQ de W5ALT

                Walt Fair, Jr., P. E. Comport Computing Specializing in Technical Engineering Software

                F Offline
                F Offline
                Fernando Padoan
                wrote on last edited by
                #7

                The author of that code has left the company long ago, so I showed it to my colleagues, trying to figure it out, and some of us agreed that he probably had to restrict the report to overdue tasks, and made it in a totally inappropriate place in code. :doh: This feature has not been used till now, when the customer requested the change that finally came to my desk. Again, without restricting, but now filtering the status... If you're ever curious about the horror, I have deleted the method.

                1 Reply Last reply
                0
                • R Richard A Dalton

                  There could be a seperate section for Coding Doh's :doh: The difference between a Coding Horror and a Coding Doh! is subtle. Both involve the desire to slap a programmer in the head. With a Coding Doh! the programmer wants to slap themselves, with a Coding Horror another programmer feels the urge to administer the slap.

                  P Offline
                  P Offline
                  peterchen
                  wrote on last edited by
                  #8

                  Richard A. Dalton wrote:

                  Both involve the desire to slap a programmer in the head.

                  One with the hand, the other with a hammer?

                  Agh! Reality! My Archnemesis![^]
                  | FoldWithUs! | sighist | WhoIncludes - Analyzing C++ include file hierarchy

                  1 Reply Last reply
                  0
                  • D Dr Walt Fair PE

                    Well, I can see how that could happen. You code up a switch statement with one case and a default, then get interrupted by something. By the time you get back to coding, you forgot about that and no one complained, so ... Not that it ever happened to me, mind you. :^) :wtf:

                    CQ de W5ALT

                    Walt Fair, Jr., P. E. Comport Computing Specializing in Technical Engineering Software

                    M Offline
                    M Offline
                    Matthew Dennis
                    wrote on last edited by
                    #9

                    Which is why TDD is so good. If you get interrupted, run your tests and you know where you are in your coding.

                    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