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 Back Room
  4. 5 years of experience but WTF!

5 years of experience but WTF!

Scheduled Pinned Locked Moved The Back Room
collaborationquestion
32 Posts 12 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.
  • P Prakash Nadar

    I was code reviewing one of my team members code change. This is how it was, void foo(...) { int abc = 0; . . . if(somecondition) { functioncall(...,abc); } else { abc = 1; functioncall(...,abc); } } the param takes either 0 or 1. what happend to boolean?!? why cant true or false be passed directly to the function? Have you guys ever experienced such absurd codeing from a 5 year experienced guy?


    -prakash -- modified at 5:16 Saturday 15th October, 2005

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

    Mr.Prakash wrote:

    void foo(...){ int abc = 0; . . . if(somecondition) { functioncall(...,abc); } else { abc = 1; functioncall(...,abc); }}

    Or how about: void foo(...) { . . . if(somecondition) { functioncall(..., 0); } else { functioncall(..., 1); } } or: void foo(...) { . . . functioncall(..., !somecondition); } or use the ?: operator. Mind you, I can write perfectly good crap when I'm in the mood, like: if(somevalue = TRUE) dosomething(); But then we use the PREFAST DDK compiler to catch this. It is interesting though, in this world of auto checking compilers etc how a code review can pull out a load of bugs and innefficiencies. Nunc est bibendum

    P 1 Reply Last reply
    0
    • L Lost User

      Vikram A Punathambekar wrote:

      BTW, the if brace is not matched.

      Is it? Looks matched to me??? Nunc est bibendum

      V Offline
      V Offline
      Vikram A Punathambekar
      wrote on last edited by
      #22

      It was not. He edited it. Now it is. :) Cheers, Vikram.


      http://www.geocities.com/vpunathambekar

      Google talk: binarybandit

      After all is said and done, much is said and little is done.

      L 1 Reply Last reply
      0
      • V Vikram A Punathambekar

        It was not. He edited it. Now it is. :) Cheers, Vikram.


        http://www.geocities.com/vpunathambekar

        Google talk: binarybandit

        After all is said and done, much is said and little is done.

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

        Ahah, that explains it. :) Nunc est bibendum

        1 Reply Last reply
        0
        • M Marc Clifton

          Mr.Prakash wrote:

          What is wrong in this? or are you sarcastic?

          Yes, I was being sarcastic. Because if you're writing:

          if (somecondition) functioncall(true);else functioncall(false);

          you might as well write:

          functioncall(somecondition);

          right? Marc My website Traceract Understanding Simple Data Binding Diary Of A CEO - Preface

          K Offline
          K Offline
          KaRl
          wrote on last edited by
          #24

          I love that one. Each time I see something like

          Marc Clifton wrote:

          if (somecondition) functioncall(true);else functioncall(false);

          or the variation

          if(condition)
          return true;
          else
          return false;

          instead of

          return condition;

          I am split between laughters and tears :sigh:


          The great error of nearly all studies of war has been to consider war as an episode in foreign policies, when it is an act of interior politics - Simone Weil Fold with us! ¤ flickr

          1 Reply Last reply
          0
          • P Prakash Nadar

            I was code reviewing one of my team members code change. This is how it was, void foo(...) { int abc = 0; . . . if(somecondition) { functioncall(...,abc); } else { abc = 1; functioncall(...,abc); } } the param takes either 0 or 1. what happend to boolean?!? why cant true or false be passed directly to the function? Have you guys ever experienced such absurd codeing from a 5 year experienced guy?


            -prakash -- modified at 5:16 Saturday 15th October, 2005

            T Offline
            T Offline
            Tim Ranker
            wrote on last edited by
            #25

            If the code is supposed to be portable and compile with any C compiler(note not C++), then the 5 year guy isn't as dumb as you think. Bool does not exist in ANSI C.

            P 1 Reply Last reply
            0
            • P Prakash Nadar

              I was code reviewing one of my team members code change. This is how it was, void foo(...) { int abc = 0; . . . if(somecondition) { functioncall(...,abc); } else { abc = 1; functioncall(...,abc); } } the param takes either 0 or 1. what happend to boolean?!? why cant true or false be passed directly to the function? Have you guys ever experienced such absurd codeing from a 5 year experienced guy?


              -prakash -- modified at 5:16 Saturday 15th October, 2005

              X Offline
              X Offline
              xlr ltspan style font size110 color 990000font we
              wrote on last edited by
              #26

              Why were you voted down for this one? Anyone care to explain?

              P R 2 Replies Last reply
              0
              • L Lost User

                Mr.Prakash wrote:

                void foo(...){ int abc = 0; . . . if(somecondition) { functioncall(...,abc); } else { abc = 1; functioncall(...,abc); }}

                Or how about: void foo(...) { . . . if(somecondition) { functioncall(..., 0); } else { functioncall(..., 1); } } or: void foo(...) { . . . functioncall(..., !somecondition); } or use the ?: operator. Mind you, I can write perfectly good crap when I'm in the mood, like: if(somevalue = TRUE) dosomething(); But then we use the PREFAST DDK compiler to catch this. It is interesting though, in this world of auto checking compilers etc how a code review can pull out a load of bugs and innefficiencies. Nunc est bibendum

                P Offline
                P Offline
                Prakash Nadar
                wrote on last edited by
                #27

                you could not actually guess the right answer coz for the right answer there are many other things involved. I just gave a small section to highlight the point of passing the param to the function.


                -prakash

                1 Reply Last reply
                0
                • X xlr ltspan style font size110 color 990000font we

                  Why were you voted down for this one? Anyone care to explain?

                  P Offline
                  P Offline
                  Prakash Nadar
                  wrote on last edited by
                  #28

                  xlr8td wrote:

                  Why were you voted down for this one? Anyone care to explain?

                  I guess many 5 year experienced guys didnt find that a problem.


                  -prakash

                  1 Reply Last reply
                  0
                  • T Tim Ranker

                    If the code is supposed to be portable and compile with any C compiler(note not C++), then the 5 year guy isn't as dumb as you think. Bool does not exist in ANSI C.

                    P Offline
                    P Offline
                    Prakash Nadar
                    wrote on last edited by
                    #29

                    Tim Ranker wrote:

                    then the 5 year guy isn't as dumb as you think. Bool does not exist in ANSI C.

                    He is, I know him for past 2 year ;)


                    -prakash

                    1 Reply Last reply
                    0
                    • P Prakash Nadar

                      I was code reviewing one of my team members code change. This is how it was, void foo(...) { int abc = 0; . . . if(somecondition) { functioncall(...,abc); } else { abc = 1; functioncall(...,abc); } } the param takes either 0 or 1. what happend to boolean?!? why cant true or false be passed directly to the function? Have you guys ever experienced such absurd codeing from a 5 year experienced guy?


                      -prakash -- modified at 5:16 Saturday 15th October, 2005

                      R Offline
                      R Offline
                      realJSOP
                      wrote on last edited by
                      #30

                      My, aren't we full of ourselves... How can anybody here agree or disagree with you without seeing th code within it's complete context. ------- sig starts "I've heard some drivers saying, 'We're going too fast here...'. If you're not here to race, go the hell home - don't come here and grumble about going too fast. Why don't you tie a kerosene rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

                      P 1 Reply Last reply
                      0
                      • X xlr ltspan style font size110 color 990000font we

                        Why were you voted down for this one? Anyone care to explain?

                        R Offline
                        R Offline
                        realJSOP
                        wrote on last edited by
                        #31

                        Most of my posts get voted down because they someone doesn't like something I said here five years ago. Go figure... ------- sig starts "I've heard some drivers saying, 'We're going too fast here...'. If you're not here to race, go the hell home - don't come here and grumble about going too fast. Why don't you tie a kerosene rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

                        1 Reply Last reply
                        0
                        • R realJSOP

                          My, aren't we full of ourselves... How can anybody here agree or disagree with you without seeing th code within it's complete context. ------- sig starts "I've heard some drivers saying, 'We're going too fast here...'. If you're not here to race, go the hell home - don't come here and grumble about going too fast. Why don't you tie a kerosene rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

                          P Offline
                          P Offline
                          Prakash Nadar
                          wrote on last edited by
                          #32

                          John Simmons / outlaw programmer wrote:

                          How can anybody here agree or disagree with you without seeing th code within it's complete context.

                          There you have a point but When I put up that post, My point was of very obvious mistake of adding an additional variable which is used in only thouse 2 lines, which a 5 year experienced guy should have avoided. Yes, I pointed out the mistake and spoke to him and he accepted his mistake and corrected the code.


                          -prakash

                          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