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

    S Offline
    S Offline
    Stan Shannon
    wrote on last edited by
    #8

    It might very well be that the param was originally intended to contain more values, and was just never changed to bool as the code requirements changed. You would certainly find examples like that in my code and I have a hell of a lot more than 5 years experience. My experience tells me that if the code is working - don't fix it. "Capitalism is the source of all true freedom."

    P 1 Reply Last reply
    0
    • S Stan Shannon

      It might very well be that the param was originally intended to contain more values, and was just never changed to bool as the code requirements changed. You would certainly find examples like that in my code and I have a hell of a lot more than 5 years experience. My experience tells me that if the code is working - don't fix it. "Capitalism is the source of all true freedom."

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

      well, The function was written by him too, btw, you think using a variable was very smart thing to do? also read this[^]


      -prakash -- modified at 11:56 Saturday 15th October, 2005

      S 1 Reply Last reply
      0
      • P Prakash Nadar

        well, The function was written by him too, btw, you think using a variable was very smart thing to do? also read this[^]


        -prakash -- modified at 11:56 Saturday 15th October, 2005

        S Offline
        S Offline
        Stan Shannon
        wrote on last edited by
        #10

        Mr.Prakash wrote:

        you think using a variable was very smart thing to do?

        Its cetainly not how I would have done it, but than, a lot of my code turns out not to be the way I would have done it given a more perfect understanding of the ultimate user requirements at the beginning of a project. One of the things that really gets under my skin is when someone looks at some code I wrote months or years before while trying to get an application finished under unrealistic deadlines, and then asks me contemptuously why I did something one way rather than another way. I stopped being a perfectionist decades ago. "Capitalism is the source of all true freedom."

        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

          R Offline
          R Offline
          retZ
          wrote on last edited by
          #11

          :confused: Doesnt sound like a big deal. A 3 byte savings if you are using C++ I guess. (not even that if it is a really old version of Visual C++) There are no failures.. only extended learning opportunities.

          P 1 Reply Last reply
          0
          • R retZ

            :confused: Doesnt sound like a big deal. A 3 byte savings if you are using C++ I guess. (not even that if it is a really old version of Visual C++) There are no failures.. only extended learning opportunities.

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

            The code untimately goes into mobile phones, so saving 3 bytes is a big deal.


            -prakash

            L 1 Reply Last reply
            0
            • S Stan Shannon

              Mr.Prakash wrote:

              you think using a variable was very smart thing to do?

              Its cetainly not how I would have done it, but than, a lot of my code turns out not to be the way I would have done it given a more perfect understanding of the ultimate user requirements at the beginning of a project. One of the things that really gets under my skin is when someone looks at some code I wrote months or years before while trying to get an application finished under unrealistic deadlines, and then asks me contemptuously why I did something one way rather than another way. I stopped being a perfectionist decades ago. "Capitalism is the source of all true freedom."

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

              That is why we always tend to do the codereview before the code is checked in so that some obvious mistakes can be caught and corrected before it is a problem in the future.


              -prakash

              1 Reply Last reply
              0
              • P Prakash Nadar

                The code untimately goes into mobile phones, so saving 3 bytes is a big deal.


                -prakash

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

                David Wulf would know but I think modern phones have about 8MB of flash, old ones maybe 256KB-1MB. Elaine :rose: The tigress is here :-D

                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

                  M Offline
                  M Offline
                  Marc Clifton
                  wrote on last edited by
                  #15

                  Mr.Prakash wrote:

                  why cant true or false be passed directly to the function?

                  Careful what you suggest. You'll end up getting code like this:

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

                  Mr.Prakash wrote:

                  a 5 year experienced guy?

                  In what, VB? Marc My website Traceract Understanding Simple Data Binding Diary Of A CEO - Preface

                  P 2 Replies Last reply
                  0
                  • M Marc Clifton

                    Mr.Prakash wrote:

                    why cant true or false be passed directly to the function?

                    Careful what you suggest. You'll end up getting code like this:

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

                    Mr.Prakash wrote:

                    a 5 year experienced guy?

                    In what, VB? Marc My website Traceract Understanding Simple Data Binding Diary Of A CEO - Preface

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

                    Marc Clifton wrote:

                    In what, VB?

                    C/C++ :sigh:


                    -prakash

                    1 Reply Last reply
                    0
                    • M Marc Clifton

                      Mr.Prakash wrote:

                      why cant true or false be passed directly to the function?

                      Careful what you suggest. You'll end up getting code like this:

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

                      Mr.Prakash wrote:

                      a 5 year experienced guy?

                      In what, VB? Marc My website Traceract Understanding Simple Data Binding Diary Of A CEO - Preface

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

                      Marc Clifton wrote:

                      Careful what you suggest. You'll end up getting code like this: if (somecondition) functioncall(true);else functioncall(false);

                      What is wrong in this? or are you sarcastic? w.r.t design of the software, passing true/false was the better way of doing it and He (dev) accepted it and he said that I am a good reviewer.:doh:


                      -prakash

                      M 1 Reply Last reply
                      0
                      • P Prakash Nadar

                        Marc Clifton wrote:

                        Careful what you suggest. You'll end up getting code like this: if (somecondition) functioncall(true);else functioncall(false);

                        What is wrong in this? or are you sarcastic? w.r.t design of the software, passing true/false was the better way of doing it and He (dev) accepted it and he said that I am a good reviewer.:doh:


                        -prakash

                        M Offline
                        M Offline
                        Marc Clifton
                        wrote on last edited by
                        #18

                        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

                        P K 2 Replies 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

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

                          Marc Clifton wrote:

                          you might as well write: functioncall(somecondition);

                          I had thought of this, but it is not always the preferred way of doing it, In this case the condition was quite complex and so using the if case was better way of doing it for readablity. plus there were other statements in if & else block. :)


                          -prakash

                          1 Reply Last reply
                          0
                          • V Vikram A Punathambekar

                            Mr.Prakash wrote:

                            Have you guys ever experienced such absurd codeing from a 5 year experienced guy?

                            In my limited corporate experience, No. :^) BTW, the if brace is not matched. Cheers, Vikram.


                            Google talk: binarybandit

                            upsdude: when I looked at laurens profile, a couple of gears got stripped in my brain. Michael Martin: Too bad she bats for the other team.

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

                            Vikram A Punathambekar wrote:

                            BTW, the if brace is not matched.

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

                            V 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

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