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

top this

Scheduled Pinned Locked Moved The Weird and The Wonderful
35 Posts 18 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

    int g = 0;
    _more:
    while(1)
    {
    g++;
    if(g < 10)
    goto _more;
    else
    goto _done;
    }

    _done:
    printf("%d\n", g);

    ...byte till it megahertz...

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

    There is no excuse for that.

    1 Reply Last reply
    0
    • L Lost User

      int g = 0;
      _more:
      while(1)
      {
      g++;
      if(g < 10)
      goto _more;
      else
      goto _done;
      }

      _done:
      printf("%d\n", g);

      ...byte till it megahertz...

      A Offline
      A Offline
      Andrew Rissing
      wrote on last edited by
      #4

      You sir...have been topped.

      int g = 0;
      

      _more:
      while(1)
      {
      g++;

                  switch (g)
                  {
                    case 0:
                          goto \_more;
                    case 1:
                          goto \_more;
                    case 2:
                          goto \_more;
                    case 3:
                          goto \_more;
                    case 4:
                          goto \_more;
                    case 5:
                          goto \_more;
                    case 6:
                          goto \_more;
                    case 7:
                          goto \_more;
                    case 8:
                          goto \_more;
                    case 9:
                          goto \_more;
                    default:
                          goto \_done;
                  }
      }
      

      _done:
      printf("%d\n", g);

      Frankly, there could always be a worse. :-D

      R L H Y 4 Replies Last reply
      0
      • A Andrew Rissing

        You sir...have been topped.

        int g = 0;
        

        _more:
        while(1)
        {
        g++;

                    switch (g)
                    {
                      case 0:
                            goto \_more;
                      case 1:
                            goto \_more;
                      case 2:
                            goto \_more;
                      case 3:
                            goto \_more;
                      case 4:
                            goto \_more;
                      case 5:
                            goto \_more;
                      case 6:
                            goto \_more;
                      case 7:
                            goto \_more;
                      case 8:
                            goto \_more;
                      case 9:
                            goto \_more;
                      default:
                            goto \_done;
                    }
        }
        

        _done:
        printf("%d\n", g);

        Frankly, there could always be a worse. :-D

        R Offline
        R Offline
        ricmil42
        wrote on last edited by
        #5

        WOW! The example by the OP was BAD, but this is worse. I just glad the loop had only 10 iterations and not 10,000. :-D

        A 1 Reply Last reply
        0
        • R ricmil42

          WOW! The example by the OP was BAD, but this is worse. I just glad the loop had only 10 iterations and not 10,000. :-D

          A Offline
          A Offline
          Andrew Rissing
          wrote on last edited by
          #6

          Thankfully, it's not real. I just took his code and applied the 'coding horror' found in the last posting here. ;)

          E 1 Reply Last reply
          0
          • A Andrew Rissing

            Thankfully, it's not real. I just took his code and applied the 'coding horror' found in the last posting here. ;)

            E Offline
            E Offline
            elchupathingy
            wrote on last edited by
            #7

            You never know something like that will pop up :/ and it will inadvertently will.

            1 Reply Last reply
            0
            • A Andrew Rissing

              You sir...have been topped.

              int g = 0;
              

              _more:
              while(1)
              {
              g++;

                          switch (g)
                          {
                            case 0:
                                  goto \_more;
                            case 1:
                                  goto \_more;
                            case 2:
                                  goto \_more;
                            case 3:
                                  goto \_more;
                            case 4:
                                  goto \_more;
                            case 5:
                                  goto \_more;
                            case 6:
                                  goto \_more;
                            case 7:
                                  goto \_more;
                            case 8:
                                  goto \_more;
                            case 9:
                                  goto \_more;
                            default:
                                  goto \_done;
                          }
              }
              

              _done:
              printf("%d\n", g);

              Frankly, there could always be a worse. :-D

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

              :thumbsup: :laugh:

              ...byte till it megahertz...

              1 Reply Last reply
              0
              • L Lost User

                int g = 0;
                _more:
                while(1)
                {
                g++;
                if(g < 10)
                goto _more;
                else
                goto _done;
                }

                _done:
                printf("%d\n", g);

                ...byte till it megahertz...

                C Offline
                C Offline
                Chris Boden
                wrote on last edited by
                #9

                I'm in tears from laughing at this.

                1 Reply Last reply
                0
                • L Lost User

                  int g = 0;
                  _more:
                  while(1)
                  {
                  g++;
                  if(g < 10)
                  goto _more;
                  else
                  goto _done;
                  }

                  _done:
                  printf("%d\n", g);

                  ...byte till it megahertz...

                  J Offline
                  J Offline
                  Jeroen De Dauw
                  wrote on last edited by
                  #10

                  Is this a real horror or an artificial one? I find it hard to believe someone can be so stupid...

                  Jeroen De Dauw
                  Blog ; Wiki

                  P 1 Reply Last reply
                  0
                  • J Jeroen De Dauw

                    Is this a real horror or an artificial one? I find it hard to believe someone can be so stupid...

                    Jeroen De Dauw
                    Blog ; Wiki

                    P Offline
                    P Offline
                    PIEBALDconsult
                    wrote on last edited by
                    #11

                    Jeroen De Dauw wrote:

                    I find it hard to believe someone can be so stupid...

                    ... and not be using VB.

                    1 Reply Last reply
                    0
                    • L Lost User

                      int g = 0;
                      _more:
                      while(1)
                      {
                      g++;
                      if(g < 10)
                      goto _more;
                      else
                      goto _done;
                      }

                      _done:
                      printf("%d\n", g);

                      ...byte till it megahertz...

                      J Offline
                      J Offline
                      Joe Programm3r
                      wrote on last edited by
                      #12

                      My eyes, my eyes, they burn.

                      1 Reply Last reply
                      0
                      • L Lost User

                        int g = 0;
                        _more:
                        while(1)
                        {
                        g++;
                        if(g < 10)
                        goto _more;
                        else
                        goto _done;
                        }

                        _done:
                        printf("%d\n", g);

                        ...byte till it megahertz...

                        S Offline
                        S Offline
                        SirTimothy
                        wrote on last edited by
                        #13

                        I've tidied up that code for you:

                        int g = 0;
                        

                        _more:
                        while((++g < 10) || (printf("%d\n", g), g < 10))
                        goto _more;

                        or:

                        printf("10\n");

                        1 Reply Last reply
                        0
                        • A Andrew Rissing

                          You sir...have been topped.

                          int g = 0;
                          

                          _more:
                          while(1)
                          {
                          g++;

                                      switch (g)
                                      {
                                        case 0:
                                              goto \_more;
                                        case 1:
                                              goto \_more;
                                        case 2:
                                              goto \_more;
                                        case 3:
                                              goto \_more;
                                        case 4:
                                              goto \_more;
                                        case 5:
                                              goto \_more;
                                        case 6:
                                              goto \_more;
                                        case 7:
                                              goto \_more;
                                        case 8:
                                              goto \_more;
                                        case 9:
                                              goto \_more;
                                        default:
                                              goto \_done;
                                      }
                          }
                          

                          _done:
                          printf("%d\n", g);

                          Frankly, there could always be a worse. :-D

                          H Offline
                          H Offline
                          hohums2
                          wrote on last edited by
                          #14

                          Looks a little like duffs device which unlike the code above was actually useful in rare cases... before compilers started to apply the optimization automatically. Oh and here's a nasty one I've actually seen:

                          while (1) //Who needs switch statements or else if
                          {
                          if (foo)
                          {
                          //Do stuff
                          break;
                          }

                           if (bill)
                           {
                               //Do stuff
                               break;
                           }
                          
                           break;
                          

                          };

                          1 Reply Last reply
                          0
                          • L Lost User

                            int g = 0;
                            _more:
                            while(1)
                            {
                            g++;
                            if(g < 10)
                            goto _more;
                            else
                            goto _done;
                            }

                            _done:
                            printf("%d\n", g);

                            ...byte till it megahertz...

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

                            This is easy to top, even if I can't post the code here for several reasons. Immagine this: - A source file with a class - All methods are static, so this is not really much of a class - The whole thing has about 7000 lines - The methods are more or less the application logic and data access for the entire application - Some methods are redundant, possible differences to the other versions are not apparent or documented. - To be precise: Nothing is commented except the many WTFs of the poor guys who tried to maintain that thing. - Several methods consist of 500+ lines of real spaghetti code - No error handling except for a few empty catch blocks - The few catch blocks that are not empty try to send meaningless or even misleading mails to the responsible developer - No apparent naming convention for variables except that the names usually are cryptic or misleading. On top of that a generous measure of German has been thrown in to make the code more readable. - The application (a ASP .Net website) has no such thing as layers. Everything was thrown into this 'class' as static methods. - One of the static methods (which also has two redundant copies which may have some significant changes - or not) tries to replace the entire data access layer. It takes about two dozen parameters and then tries to construct the required SQL command in about 500 lines of twisted code. Changes are next to impossible without side effects as each snippet of code is used to construct very different SQL statements. If nested select statements are needed, they are constructed in similar static functions. - Once all SQL commands has been constructed, data access is done in the following fashion: First, a simple sql command is issued to get a DataSet as a result. The DataLines are then thrown away. The 'Developer' was just to lazy to initialize the DataSet the normal way. Then the thing tries to fill all tables in the DataSet with the prepared SQL commands, each table separately. If there is no error (a rare event), the whole thing is finished by declaring about 30 relations between the tables in the DataSet. This usually is the end of it, as the generated SQL commands usually do not fill the table precisely enough to enforce any constraints or relations. This thing has nothing, no architecture, no class design, no readability, no maintainability. It is the ultimate coding horror. It is really the first piece of code I ever had to work with where I say that the 'developer' got nothing right. Not the least bit and not even b

                            I Y M R 4 Replies Last reply
                            0
                            • L Lost User

                              This is easy to top, even if I can't post the code here for several reasons. Immagine this: - A source file with a class - All methods are static, so this is not really much of a class - The whole thing has about 7000 lines - The methods are more or less the application logic and data access for the entire application - Some methods are redundant, possible differences to the other versions are not apparent or documented. - To be precise: Nothing is commented except the many WTFs of the poor guys who tried to maintain that thing. - Several methods consist of 500+ lines of real spaghetti code - No error handling except for a few empty catch blocks - The few catch blocks that are not empty try to send meaningless or even misleading mails to the responsible developer - No apparent naming convention for variables except that the names usually are cryptic or misleading. On top of that a generous measure of German has been thrown in to make the code more readable. - The application (a ASP .Net website) has no such thing as layers. Everything was thrown into this 'class' as static methods. - One of the static methods (which also has two redundant copies which may have some significant changes - or not) tries to replace the entire data access layer. It takes about two dozen parameters and then tries to construct the required SQL command in about 500 lines of twisted code. Changes are next to impossible without side effects as each snippet of code is used to construct very different SQL statements. If nested select statements are needed, they are constructed in similar static functions. - Once all SQL commands has been constructed, data access is done in the following fashion: First, a simple sql command is issued to get a DataSet as a result. The DataLines are then thrown away. The 'Developer' was just to lazy to initialize the DataSet the normal way. Then the thing tries to fill all tables in the DataSet with the prepared SQL commands, each table separately. If there is no error (a rare event), the whole thing is finished by declaring about 30 relations between the tables in the DataSet. This usually is the end of it, as the generated SQL commands usually do not fill the table precisely enough to enforce any constraints or relations. This thing has nothing, no architecture, no class design, no readability, no maintainability. It is the ultimate coding horror. It is really the first piece of code I ever had to work with where I say that the 'developer' got nothing right. Not the least bit and not even b

                              I Offline
                              I Offline
                              imagiro
                              wrote on last edited by
                              #16

                              And this horrifies you? In my last job my predecessor always wrote code like this. When you said that there was some German I really thought you are talking about him! There is only one thing I don't understand. This guy gets one really nice job after the other and earns at least twice as much money as I do. I guess this is just because none of his customers can read his code - because they are no programmers and also because of the reasons you just mentioned.. X|

                              L M 2 Replies Last reply
                              0
                              • A Andrew Rissing

                                You sir...have been topped.

                                int g = 0;
                                

                                _more:
                                while(1)
                                {
                                g++;

                                            switch (g)
                                            {
                                              case 0:
                                                    goto \_more;
                                              case 1:
                                                    goto \_more;
                                              case 2:
                                                    goto \_more;
                                              case 3:
                                                    goto \_more;
                                              case 4:
                                                    goto \_more;
                                              case 5:
                                                    goto \_more;
                                              case 6:
                                                    goto \_more;
                                              case 7:
                                                    goto \_more;
                                              case 8:
                                                    goto \_more;
                                              case 9:
                                                    goto \_more;
                                              default:
                                                    goto \_done;
                                            }
                                }
                                

                                _done:
                                printf("%d\n", g);

                                Frankly, there could always be a worse. :-D

                                Y Offline
                                Y Offline
                                Yusuf
                                wrote on last edited by
                                #17

                                That was not bad, it was very very bad

                                Andrew Rissing wrote:

                                int g = 0; _more: while(1) { g++;

                                you started with g++, which has a value of 1, it will never be less than 1 then you do

                                Andrew Rissing wrote:

                                switch (g) { case 0: goto _more;

                                You may as well continue case 10, case 11 .......case 9999 :omg: :wtf:

                                Yusuf May I help you?

                                1 Reply Last reply
                                0
                                • L Lost User

                                  This is easy to top, even if I can't post the code here for several reasons. Immagine this: - A source file with a class - All methods are static, so this is not really much of a class - The whole thing has about 7000 lines - The methods are more or less the application logic and data access for the entire application - Some methods are redundant, possible differences to the other versions are not apparent or documented. - To be precise: Nothing is commented except the many WTFs of the poor guys who tried to maintain that thing. - Several methods consist of 500+ lines of real spaghetti code - No error handling except for a few empty catch blocks - The few catch blocks that are not empty try to send meaningless or even misleading mails to the responsible developer - No apparent naming convention for variables except that the names usually are cryptic or misleading. On top of that a generous measure of German has been thrown in to make the code more readable. - The application (a ASP .Net website) has no such thing as layers. Everything was thrown into this 'class' as static methods. - One of the static methods (which also has two redundant copies which may have some significant changes - or not) tries to replace the entire data access layer. It takes about two dozen parameters and then tries to construct the required SQL command in about 500 lines of twisted code. Changes are next to impossible without side effects as each snippet of code is used to construct very different SQL statements. If nested select statements are needed, they are constructed in similar static functions. - Once all SQL commands has been constructed, data access is done in the following fashion: First, a simple sql command is issued to get a DataSet as a result. The DataLines are then thrown away. The 'Developer' was just to lazy to initialize the DataSet the normal way. Then the thing tries to fill all tables in the DataSet with the prepared SQL commands, each table separately. If there is no error (a rare event), the whole thing is finished by declaring about 30 relations between the tables in the DataSet. This usually is the end of it, as the generated SQL commands usually do not fill the table precisely enough to enforce any constraints or relations. This thing has nothing, no architecture, no class design, no readability, no maintainability. It is the ultimate coding horror. It is really the first piece of code I ever had to work with where I say that the 'developer' got nothing right. Not the least bit and not even b

                                  Y Offline
                                  Y Offline
                                  Yusuf
                                  wrote on last edited by
                                  #18

                                  You mean such class exist in production code. :rolleyes: :omg:

                                  Yusuf May I help you?

                                  L 1 Reply Last reply
                                  0
                                  • L Lost User

                                    int g = 0;
                                    _more:
                                    while(1)
                                    {
                                    g++;
                                    if(g < 10)
                                    goto _more;
                                    else
                                    goto _done;
                                    }

                                    _done:
                                    printf("%d\n", g);

                                    ...byte till it megahertz...

                                    Y Offline
                                    Y Offline
                                    Yusuf
                                    wrote on last edited by
                                    #19

                                    The instruction was very clear, exercise all aspects of the language features.

                                    Yusuf May I help you?

                                    L 1 Reply Last reply
                                    0
                                    • I imagiro

                                      And this horrifies you? In my last job my predecessor always wrote code like this. When you said that there was some German I really thought you are talking about him! There is only one thing I don't understand. This guy gets one really nice job after the other and earns at least twice as much money as I do. I guess this is just because none of his customers can read his code - because they are no programmers and also because of the reasons you just mentioned.. X|

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

                                      Then chances are good that we are talking about the same guy. Or even worse: There are more of his kind around than we fear. We could make a call to Palermo, so that some nice men pick both of them up for a boat tour. Just to make sure that they never ever do such things again.

                                      A while ago he asked me what he should have printed on my business cards. I said 'Wizard'. I read books which nobody else understand. Then I do something which nobody understands. After that the computer does something which nobody understands. When asked, I say things about the results which nobody understand. But everybody expects miracles from me on a regular basis. Looks to me like the classical definition of a wizard.

                                      I 1 Reply Last reply
                                      0
                                      • Y Yusuf

                                        You mean such class exist in production code. :rolleyes: :omg:

                                        Yusuf May I help you?

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

                                        Oh yes. I doubt this man ever distinguished between production code or any other kind. And testing goes only far enough to sucessfully eliminate any exceptions by catching them in empty catch blocks. After that we can simply pretend that nothing happened and the man never even tried to get the thing working properly. This way everything appears to be ok and the users don't even suspect how bad the program really is. I am completing an entirely new application to replace it and ironically the users keep complaining about error messages which correctly report any inconsistencies in the database. They refuse to believe that the 'good' old application simply swept all errors under the rug.

                                        A while ago he asked me what he should have printed on my business cards. I said 'Wizard'. I read books which nobody else understand. Then I do something which nobody understands. After that the computer does something which nobody understands. When asked, I say things about the results which nobody understand. But everybody expects miracles from me on a regular basis. Looks to me like the classical definition of a wizard.

                                        1 Reply Last reply
                                        0
                                        • Y Yusuf

                                          The instruction was very clear, exercise all aspects of the language features.

                                          Yusuf May I help you?

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

                                          +3 Twas more like "as many features as you can muster" ;P

                                          ...byte till it megahertz...

                                          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