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'm speechless about this piece of code.

I'm speechless about this piece of code.

Scheduled Pinned Locked Moved The Weird and The Wonderful
ruby
34 Posts 17 Posters 215 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.
  • P Paddy Boyd

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

    N Offline
    N Offline
    NormDroid
    wrote on last edited by
    #25

    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

    P 1 Reply Last reply
    0
    • N NormDroid

      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

      P Offline
      P Offline
      Paddy Boyd
      wrote on last edited by
      #26

      I'm not sure that compiles... ;)

      N 1 Reply Last reply
      0
      • P Paddy Boyd

        I'm not sure that compiles... ;)

        N Offline
        N Offline
        NormDroid
        wrote on last edited by
        #27

        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

        1 Reply Last reply
        0
        • P Paddy Boyd

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

          C Offline
          C Offline
          codemunkeh
          wrote on last edited by
          #28

          catch (System.OutOfMemoryException) { GetHelpFromAnotherMuppet(); }


          Ninja (the Nerd)
          Confused? You will be...

          1 Reply Last reply
          0
          • P Pete OHanlon

            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.

            C Offline
            C Offline
            codemunkeh
            wrote on last edited by
            #29

            Then even the lead developer would be shocking.


            Ninja (the Nerd)
            Confused? You will be...

            1 Reply Last reply
            0
            • P Pete OHanlon

              I've just read an article that included this little gem

              ://it checks it contains 11 char (dd/MMM/yyyy) 
              if (Convert.ToInt16(chkdate.Length.ToString()) != 11) 
              { 
                //if it does not have 11 char then it will return false 
                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.

              M Offline
              M Offline
              Michael Pauli
              wrote on last edited by
              #30

              Why can't not ONE of you folkes be grown up enough to simply say that the rubbish: ://it checks if it contains 11 char (dd/MMM/yyyy) if (Convert.ToInt16(chkdate.Length.ToString()) != 11) { // Do something if not. } SHOULD be: :// it checks if it contains 11 char (dd/MMM/yyyy) if (chkdate.Length != 11) { // Do something if not. } How hard can it be? It's OK to pinpoint bad code like that but it's not OK not to come up with a useable alternative.

              Michael M., mm it-consult dk.

              T 1 Reply Last reply
              0
              • P Pete OHanlon

                I've just read an article that included this little gem

                ://it checks it contains 11 char (dd/MMM/yyyy) 
                if (Convert.ToInt16(chkdate.Length.ToString()) != 11) 
                { 
                  //if it does not have 11 char then it will return false 
                  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.

                T Offline
                T Offline
                Tony Wesley
                wrote on last edited by
                #31

                Pete O`Hanlon wrote:

                : //it checks it contains 11 char (dd/MMM/yyyy) if (Convert.ToInt16(chkdate.Length.ToString()) != 11) { //if it does not have 11 char then it will return false return false; }

                Shouldn't the comparison do this? :laugh: if (chkdate.Length.ToString() != "11")

                M 1 Reply Last reply
                0
                • M Michael Pauli

                  Why can't not ONE of you folkes be grown up enough to simply say that the rubbish: ://it checks if it contains 11 char (dd/MMM/yyyy) if (Convert.ToInt16(chkdate.Length.ToString()) != 11) { // Do something if not. } SHOULD be: :// it checks if it contains 11 char (dd/MMM/yyyy) if (chkdate.Length != 11) { // Do something if not. } How hard can it be? It's OK to pinpoint bad code like that but it's not OK not to come up with a useable alternative.

                  Michael M., mm it-consult dk.

                  T Offline
                  T Offline
                  Tony Wesley
                  wrote on last edited by
                  #32

                  Michael Mogensen wrote:

                  Why can't not ONE of you folkes be grown up enough to simply say...

                  Michael, Is your sense of humor having a bad day? But if we are geting serious, I'd like to point out that your question contains a double negative and means the opposite of your apparent intended meaning.

                  1 Reply Last reply
                  0
                  • T Tony Wesley

                    Pete O`Hanlon wrote:

                    : //it checks it contains 11 char (dd/MMM/yyyy) if (Convert.ToInt16(chkdate.Length.ToString()) != 11) { //if it does not have 11 char then it will return false return false; }

                    Shouldn't the comparison do this? :laugh: if (chkdate.Length.ToString() != "11")

                    M Offline
                    M Offline
                    Michael Pauli
                    wrote on last edited by
                    #33

                    ...Double negative... I give up... SS... forget it... Not beeing 100% into C# (I'm c/cpp) I suppose that this issue is something in the area of 'to get the types right' right? (ough double 'right' ... sorry) If this is string: chkdate, then this is int: chkdate.length and then I compare 11 to int which is ok, or?

                    Michael M., mm it-consult dk.

                    T 1 Reply Last reply
                    0
                    • M Michael Pauli

                      ...Double negative... I give up... SS... forget it... Not beeing 100% into C# (I'm c/cpp) I suppose that this issue is something in the area of 'to get the types right' right? (ough double 'right' ... sorry) If this is string: chkdate, then this is int: chkdate.length and then I compare 11 to int which is ok, or?

                      Michael M., mm it-consult dk.

                      T Offline
                      T Offline
                      Tony Wesley
                      wrote on last edited by
                      #34

                      Michael, I'm far from 100% into C#, like you, I'm a c/c++ guy. (We still have lots of stuff that's says it's c++ but it's mostly old style C). Anyway, this is an issue of getting the types right. And I was just being a smart alec. -- Tony

                      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