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. The Lounge
  3. Appalling Coding Technique

Appalling Coding Technique

Scheduled Pinned Locked Moved The Lounge
linuxdebuggingquestionlounge
32 Posts 21 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.
  • J James Spibey

    I've just been trying to debug some old C code and I stumbled across this little beauty

    if ( CANT ValidateIncomingGoods(pMsg))
    {
    ...

    I'm thinking, 'WTF is this CANT thing?' So I grep around a little and at the top of the file I find

    #define CANT !

    Time for random acts of violence around the office. Cheers James

    S Offline
    S Offline
    Stephane Rodriguez
    wrote on last edited by
    #2

    Oh :omg: I have seen that one too in an old code I was expected to maintain : IFP(ValidateIncomingGoods(pMsg)) So i started wondering what could have been the magical things behind IFP. I was thinking about run-time object validation, and stuff like that. It fell short, #define IFP if :omg: :omg: :omg:

    M M J J 4 Replies Last reply
    0
    • J James Spibey

      I've just been trying to debug some old C code and I stumbled across this little beauty

      if ( CANT ValidateIncomingGoods(pMsg))
      {
      ...

      I'm thinking, 'WTF is this CANT thing?' So I grep around a little and at the top of the file I find

      #define CANT !

      Time for random acts of violence around the office. Cheers James

      R Offline
      R Offline
      Roger Allen
      wrote on last edited by
      #3

      :rolleyes: Not dead yet! :suss: Roger Allen Sonork 100.10016 In case you're worried about what's going to become of the younger generation, it's going to grow up and start worrying about the younger generation. - Roger Allen, but not me!

      1 Reply Last reply
      0
      • J James Spibey

        I've just been trying to debug some old C code and I stumbled across this little beauty

        if ( CANT ValidateIncomingGoods(pMsg))
        {
        ...

        I'm thinking, 'WTF is this CANT thing?' So I grep around a little and at the top of the file I find

        #define CANT !

        Time for random acts of violence around the office. Cheers James

        Richard DeemingR Offline
        Richard DeemingR Offline
        Richard Deeming
        wrote on last edited by
        #4

        :laugh: Sounds like a frustrated VB developer!


        "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

        "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

        1 Reply Last reply
        0
        • J James Spibey

          I've just been trying to debug some old C code and I stumbled across this little beauty

          if ( CANT ValidateIncomingGoods(pMsg))
          {
          ...

          I'm thinking, 'WTF is this CANT thing?' So I grep around a little and at the top of the file I find

          #define CANT !

          Time for random acts of violence around the office. Cheers James

          S Offline
          S Offline
          Simon Walton
          wrote on last edited by
          #5

          Almost as great as

          #define private public

          :-D

          Simon Walton
          Sonork: 10024

          P

          T 1 Reply Last reply
          0
          • S Stephane Rodriguez

            Oh :omg: I have seen that one too in an old code I was expected to maintain : IFP(ValidateIncomingGoods(pMsg)) So i started wondering what could have been the magical things behind IFP. I was thinking about run-time object validation, and stuff like that. It fell short, #define IFP if :omg: :omg: :omg:

            M Offline
            M Offline
            Matt Newman
            wrote on last edited by
            #6

            .S.Rod. wrote: #define IFP if :omg::wtf::omg::wtf::omg::wtf: -:suss:Matt Newman / Windows XP Activist:suss:
            "Well, the guy that's giving you a hard time is a f***in moron, and you can tell him thats straight from another Linux user." - John Simmons on Linux Users
            Just do the American thing and shoot him... - Jim Crafton on Linux Users
            Wh3n my l33t skillz 1mpr0v3, I w1ll h4ck M$, 4nd th3n wh0 w1ll b3 l4ugh1ng ? N0t Bill. H4 h4 h4 h4 h4 h4 h4. - Christian Graus

            1 Reply Last reply
            0
            • S Stephane Rodriguez

              Oh :omg: I have seen that one too in an old code I was expected to maintain : IFP(ValidateIncomingGoods(pMsg)) So i started wondering what could have been the magical things behind IFP. I was thinking about run-time object validation, and stuff like that. It fell short, #define IFP if :omg: :omg: :omg:

              M Offline
              M Offline
              Megan Forbes
              wrote on last edited by
              #7

              Where do you guys find these people? :eek:


              I knew it would end badly when I first met Chris in a Canberra alleyway and he said 'try some - it won't hurt you'..... - Christian Graus on Code Project outages A moment of silence please. A programmer's best friend has passed beyond that great exception in the sky.... - Mark Conger on "The coffee machine has died"

              R 1 Reply Last reply
              0
              • J James Spibey

                I've just been trying to debug some old C code and I stumbled across this little beauty

                if ( CANT ValidateIncomingGoods(pMsg))
                {
                ...

                I'm thinking, 'WTF is this CANT thing?' So I grep around a little and at the top of the file I find

                #define CANT !

                Time for random acts of violence around the office. Cheers James

                D Offline
                D Offline
                Daniel Turini
                wrote on last edited by
                #8

                It looks someone being funny. In old college times, we used to work Turbo C 2.0 on computers (a 286 was quite expensive that time, about $5000) which were shared with other courses, so they were always occupied. To speed up people freeing a computer, I added the following "feature" to stdio.h, on the best machine we got:

                #define while(x) while(1)

                Obviously, I used "touch" to reset the file date and time back to the original one. People blamed the computer "this machine is fast but is damaged" :-O My latest article: SQL Server DO's and DONT's[^]

                S 1 Reply Last reply
                0
                • D Daniel Turini

                  It looks someone being funny. In old college times, we used to work Turbo C 2.0 on computers (a 286 was quite expensive that time, about $5000) which were shared with other courses, so they were always occupied. To speed up people freeing a computer, I added the following "feature" to stdio.h, on the best machine we got:

                  #define while(x) while(1)

                  Obviously, I used "touch" to reset the file date and time back to the original one. People blamed the computer "this machine is fast but is damaged" :-O My latest article: SQL Server DO's and DONT's[^]

                  S Offline
                  S Offline
                  Simon Walton
                  wrote on last edited by
                  #9

                  Daniel Turini wrote: #define while(x) while(1) Priceless. :-D I didn't know you could use x to stand for anything in a define.

                  Simon Walton
                  Sonork: 10024

                  P

                  1 Reply Last reply
                  0
                  • J James Spibey

                    I've just been trying to debug some old C code and I stumbled across this little beauty

                    if ( CANT ValidateIncomingGoods(pMsg))
                    {
                    ...

                    I'm thinking, 'WTF is this CANT thing?' So I grep around a little and at the top of the file I find

                    #define CANT !

                    Time for random acts of violence around the office. Cheers James

                    D Offline
                    D Offline
                    David Patrick
                    wrote on last edited by
                    #10

                    I'm sorry .. but I actually liked that .. certainly makes it nice and readable.

                    T D 2 Replies Last reply
                    0
                    • S Simon Walton

                      Almost as great as

                      #define private public

                      :-D

                      Simon Walton
                      Sonork: 10024

                      P

                      T Offline
                      T Offline
                      Todd C Wilson
                      wrote on last edited by
                      #11

                      Actualy, I've had to resort to doing that exactly once to hack around the broken Microsoft STL headers... simply no other way to get it to work, other than using STLPort, which the PHB's refuses to use since it wasn't a "commerical" product


                      Visual Studio Favorites - improve your development! GUIgui - skin your apps without XP

                      1 Reply Last reply
                      0
                      • D David Patrick

                        I'm sorry .. but I actually liked that .. certainly makes it nice and readable.

                        T Offline
                        T Offline
                        Tim Smith
                        wrote on last edited by
                        #12

                        :~ Tim Smith I'm going to patent thought. I have yet to see any prior art.

                        1 Reply Last reply
                        0
                        • J James Spibey

                          I've just been trying to debug some old C code and I stumbled across this little beauty

                          if ( CANT ValidateIncomingGoods(pMsg))
                          {
                          ...

                          I'm thinking, 'WTF is this CANT thing?' So I grep around a little and at the top of the file I find

                          #define CANT !

                          Time for random acts of violence around the office. Cheers James

                          M Offline
                          M Offline
                          Maximilien
                          wrote on last edited by
                          #13

                          At a company I used to work, there was a bunch of francophone linguist that were really good in their field of work, but didn't know much in programming, and since they had to work in the code to implement their things, someone ( before I worked there ) decided to redefine some of the keyword to be in french...

                          #define for pour
                          #define if si
                          #define else sinon
                          ...

                          so in some source files, there was a lot of french code mixed in! Max.

                          1 Reply Last reply
                          0
                          • J James Spibey

                            I've just been trying to debug some old C code and I stumbled across this little beauty

                            if ( CANT ValidateIncomingGoods(pMsg))
                            {
                            ...

                            I'm thinking, 'WTF is this CANT thing?' So I grep around a little and at the top of the file I find

                            #define CANT !

                            Time for random acts of violence around the office. Cheers James

                            A Offline
                            A Offline
                            Alvaro Mendez
                            wrote on last edited by
                            #14

                            Well, you have to give the guy some credit for trying to make the code more readable. Did you know that the C++ Standard Library has these defines:

                            #define and &&
                            #define and_eq &=
                            #define bitand &
                            #define bitor |
                            #define compl ~
                            #define not !
                            #define not_eq !=
                            #define or ||
                            #define or_eq |=
                            #define xor ^
                            #define xor_eq ^=

                            I don't use them myself (I'm used to the cryptic syntax) but doing so can definitely improve readability. Regards, Alvaro


                            Well done is better than well said. -- Benjamin Franklin (I actually prefer medium-well.)

                            D 1 Reply Last reply
                            0
                            • D David Patrick

                              I'm sorry .. but I actually liked that .. certainly makes it nice and readable.

                              D Offline
                              D Offline
                              Daniel Turini
                              wrote on last edited by
                              #15

                              So... It was YOU who did it!!! Only one person in the world can like it :) My latest article: SQL Server DO's and DONT's[^]

                              1 Reply Last reply
                              0
                              • J James Spibey

                                I've just been trying to debug some old C code and I stumbled across this little beauty

                                if ( CANT ValidateIncomingGoods(pMsg))
                                {
                                ...

                                I'm thinking, 'WTF is this CANT thing?' So I grep around a little and at the top of the file I find

                                #define CANT !

                                Time for random acts of violence around the office. Cheers James

                                J Offline
                                J Offline
                                Joao Vaz
                                wrote on last edited by
                                #16

                                The virtues of Hungarian notation :laugh: Cheers,Joao Vaz And if your dream is to care for your family, to put food on the table, to provide them with an education and a good home, then maybe suffering through an endless, pointless, boring job will seem to have purpose. And you will realize how even a rock can change the world, simply by remaining obstinately stationary.-Shog9 Remember just because a good thing comes to an end, doesn't mean that the next one can't be better.-Chris Meech

                                1 Reply Last reply
                                0
                                • M Megan Forbes

                                  Where do you guys find these people? :eek:


                                  I knew it would end badly when I first met Chris in a Canberra alleyway and he said 'try some - it won't hurt you'..... - Christian Graus on Code Project outages A moment of silence please. A programmer's best friend has passed beyond that great exception in the sky.... - Mark Conger on "The coffee machine has died"

                                  R Offline
                                  R Offline
                                  Roger Wright
                                  wrote on last edited by
                                  #17

                                  Megan Forbes wrote: Where do you guys find these people? Coders 'R' Us. Either that, or they get them free in their breakfast cereal! You've got to be careful about criticising though... I once bashed a particularly onerous piece of cryptic spaghetti code I was assigned to port to a new system. My boss was less than sympathetic, as (unknown to me) he had written it 10 years before.:-O "My child was Inmate of the Month at Mohave County Jail" - Bumper Sticker in Bullhead City, AZ

                                  A 1 Reply Last reply
                                  0
                                  • J James Spibey

                                    I've just been trying to debug some old C code and I stumbled across this little beauty

                                    if ( CANT ValidateIncomingGoods(pMsg))
                                    {
                                    ...

                                    I'm thinking, 'WTF is this CANT thing?' So I grep around a little and at the top of the file I find

                                    #define CANT !

                                    Time for random acts of violence around the office. Cheers James

                                    P Offline
                                    P Offline
                                    Phil J Pearson
                                    wrote on last edited by
                                    #18

                                    Many years ago I remember programming in PL/M (I think that was the language) with a construct like:

                                    REPEAT
                                    ...
                                    UNTIL the$cows$come$home

                                    with the equivalent (I can't remember the language) of:

                                    #define the$cows$come$home 0

                                    It semmed amusing at the time...


                                    The opinions expressed in this communication do not necessarily represent those of the author (especially if you find them impolite, discourteous or inflammatory).

                                    1 Reply Last reply
                                    0
                                    • S Stephane Rodriguez

                                      Oh :omg: I have seen that one too in an old code I was expected to maintain : IFP(ValidateIncomingGoods(pMsg)) So i started wondering what could have been the magical things behind IFP. I was thinking about run-time object validation, and stuff like that. It fell short, #define IFP if :omg: :omg: :omg:

                                      J Offline
                                      J Offline
                                      Joao Vaz
                                      wrote on last edited by
                                      #19

                                      .S.Rod. wrote: It fell short, #define IFP if Yikes :eek: , there are some strange guys in the force ... Cheers,Joao Vaz And if your dream is to care for your family, to put food on the table, to provide them with an education and a good home, then maybe suffering through an endless, pointless, boring job will seem to have purpose. And you will realize how even a rock can change the world, simply by remaining obstinately stationary.-Shog9 Remember just because a good thing comes to an end, doesn't mean that the next one can't be better.-Chris Meech

                                      1 Reply Last reply
                                      0
                                      • J James Spibey

                                        I've just been trying to debug some old C code and I stumbled across this little beauty

                                        if ( CANT ValidateIncomingGoods(pMsg))
                                        {
                                        ...

                                        I'm thinking, 'WTF is this CANT thing?' So I grep around a little and at the top of the file I find

                                        #define CANT !

                                        Time for random acts of violence around the office. Cheers James

                                        J Offline
                                        J Offline
                                        Jason Gerard
                                        wrote on last edited by
                                        #20

                                        Here's some nice indenting that a co-worker of mine practices. if(something) { while(somethingElse) { // some crap code here // some more crap here } }
                                        Jason Gerard "This almost never matters, except quite often."

                                        S 1 Reply Last reply
                                        0
                                        • J Jason Gerard

                                          Here's some nice indenting that a co-worker of mine practices. if(something) { while(somethingElse) { // some crap code here // some more crap here } }
                                          Jason Gerard "This almost never matters, except quite often."

                                          S Offline
                                          S Offline
                                          Stephane Rodriguez
                                          wrote on last edited by
                                          #21

                                          Sometimes unfortunately produced by source code diff mergers such as Clearcase and Araxis.

                                          J 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