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

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

                      C Offline
                      C Offline
                      Chris Maunder
                      wrote on last edited by
                      #22

                      James Spibey wrote: Time for random acts of violence around the office. Ah...A new sig :-D cheers, Chris Maunder Time for random acts of violence around the office - James Spibey

                      J 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

                        R Offline
                        R Offline
                        Ray Cassick
                        wrote on last edited by
                        #23

                        Aaaaaaaaaaaaaa I came across something similar.. Someone around here had redefined the following

                        EQUALTO
                        ASSIGNTO
                        GTRTHN (greater than)
                        LESTHN (less than)
                        GTRLES (greater than or less than)
                        .
                        .
                        .

                        You get the idea... Made for some interesting (and suprisingly readable) code, but drove some younger coders NUTS! Paul Watson wrote: At the end of the day it is what you produce that counts, not how many doctorates you have on the wall.

                        R 1 Reply Last reply
                        0
                        • R Ray Cassick

                          Aaaaaaaaaaaaaa I came across something similar.. Someone around here had redefined the following

                          EQUALTO
                          ASSIGNTO
                          GTRTHN (greater than)
                          LESTHN (less than)
                          GTRLES (greater than or less than)
                          .
                          .
                          .

                          You get the idea... Made for some interesting (and suprisingly readable) code, but drove some younger coders NUTS! Paul Watson wrote: At the end of the day it is what you produce that counts, not how many doctorates you have on the wall.

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

                          Perhaps an ex COBOL programmer? 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!

                          R 1 Reply Last reply
                          0
                          • C Chris Maunder

                            James Spibey wrote: Time for random acts of violence around the office. Ah...A new sig :-D cheers, Chris Maunder Time for random acts of violence around the office - James Spibey

                            J Offline
                            J Offline
                            James Spibey
                            wrote on last edited by
                            #25

                            Chris Maunder wrote: Ah...A new sig Imortalised at last. My work here is done :) Cheers James

                            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
                              Atlantys
                              wrote on last edited by
                              #26

                              I've seen: #define void int :wtf::omg::eek: That's why I ramble so much. If you're short and quotable, there's a much greater danger of ending up in a sig. [Christopher Duncan on how to prevent yourself from ending up in a sig]

                              1 Reply Last reply
                              0
                              • R Roger Wright

                                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 Offline
                                A Offline
                                Atlantys
                                wrote on last edited by
                                #27

                                Roger Wright wrote: My boss was less than sympathetic, as (unknown to me) he had written it 10 years before. Been there before. I'm....more vocal than I should be when it comes to other people's code that doesn't work properly. So when I told our team's architect "Someone did a buck-up job here".... well... it wasn't pretty. :-O That's why I ramble so much. If you're short and quotable, there's a much greater danger of ending up in a sig. [Christopher Duncan on how to prevent yourself from ending up in a sig]

                                1 Reply Last reply
                                0
                                • A Alvaro Mendez

                                  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 Offline
                                  D Offline
                                  Daniel Turini
                                  wrote on last edited by
                                  #28

                                  You friend is only following the ISO 646 rules. You can also do the following on Visual C++

                                  #include

                                  My latest article: SQL Server DO's and DONT's[^]

                                  1 Reply Last reply
                                  0
                                  • R Roger Allen

                                    Perhaps an ex COBOL programmer? 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!

                                    R Offline
                                    R Offline
                                    Ray Cassick
                                    wrote on last edited by
                                    #29

                                    This code was in a project written for an OS/2 based Unified messaging system that used modules written in: COBOL C Pascal Rexx So this was entirely possible... never gave that much of a thought before... The code was still hell to read... and the GUI!... UGH! Looked like it was designed by a company that made tile mosaics... No allignment of GUI elements, no text boxes the same size, on the same form... what a mess... and to top it all off, it was supposed to connect to a Lotus Notes server! No wonder it died.... Paul Watson wrote: At the end of the day it is what you produce that counts, not how many doctorates you have on the wall.

                                    1 Reply Last reply
                                    0
                                    • S Stephane Rodriguez

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

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

                                      Seeing as how we don't use these and I've stood over his shoulder before as he coded, I know this is not the case. Jason Gerard "This almost never matters, except quite often."

                                      S 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
                                        Jon Newman
                                        wrote on last edited by
                                        #31

                                        .S.Rod. wrote: #define IFP if Did you find #define if ifp too? because he really should be shot then.

                                        We brought out this new and very similar version of our expensive software because the old version was......old....It's a good enough excuse for Microsoft so its fine for us.

                                        1 Reply Last reply
                                        0
                                        • J Jason Gerard

                                          Seeing as how we don't use these and I've stood over his shoulder before as he coded, I know this is not the case. Jason Gerard "This almost never matters, except quite often."

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

                                          So I guess my effort to save him is useless. ;P

                                          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