5 years of experience but WTF!
-
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
-
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
I think we all have moments of stupidity. If this is an isolated incident, then I would cut the guy some slack. But if his code runs rampant with this sort of stuff, then you may need to have a talk with him.
Picture a huge catholic cathedral. In it there's many people, including a gregorian monk choir. You know, those who sing beautifully. Then they start singing, in latin, as they always do: "Ad hominem..." -Jörgen Sigvardsson
-
I think we all have moments of stupidity. If this is an isolated incident, then I would cut the guy some slack. But if his code runs rampant with this sort of stuff, then you may need to have a talk with him.
Picture a huge catholic cathedral. In it there's many people, including a gregorian monk choir. You know, those who sing beautifully. Then they start singing, in latin, as they always do: "Ad hominem..." -Jörgen Sigvardsson
Well, this was one of the 3 stupid mistakes he did, :sigh:
-prakash
-
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
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.
-
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
Mr.Prakash wrote:
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?
Without context it is hard to tell if it is absurd or not[assuming there was a good variable name rather than abc :) ]. There are several things that come to mind for why a person might do this, so for example what language was it written in [in ansi C there is no bool]. To find out for sure just go ask your teammate why it was done that way. Quran Translation Intro Discover
-
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.
Vikram A Punathambekar wrote:
BTW, the if brace is not matched.
Thanks.
-prakash
-
Mr.Prakash wrote:
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?
Without context it is hard to tell if it is absurd or not[assuming there was a good variable name rather than abc :) ]. There are several things that come to mind for why a person might do this, so for example what language was it written in [in ansi C there is no bool]. To find out for sure just go ask your teammate why it was done that way. Quran Translation Intro Discover
well, my point was on absurd coding, so, that implies boolean is a valid datatype on whatever compiler i am using :)
A.A. wrote:
To find out for sure just go ask your teammate why it was done that way.
I did, his answer was that he wanted to store a logical value in a structure,
struct somestruct
{
.
.
unsigned int bOthervars:1; //existing vars
U32 flag; //He added this
}So I asked why did he did not use the bit fields like other members of the struct, his answer was that he could not define this way
unsigned int flag:0;
:mad:
-prakash
-
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
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."
-
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."
-
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."
-
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
-
: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.
The code untimately goes into mobile phones, so saving 3 bytes is a big deal.
-prakash
-
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."
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
-
The code untimately goes into mobile phones, so saving 3 bytes is a big deal.
-prakash
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
-
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
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
-
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
Marc Clifton wrote:
In what, VB?
C/C++ :sigh:
-prakash
-
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
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
-
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
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
-
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
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
-
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.