I have a problem with the way Subtle logic errors section is phrased.
if(hidden){show();}else{hide();}
is not a clearer way to write
if(!hidden){show();}else{hide();}
It's different code. Did you mean that a bug was fixed, and not a refactor occured?
Same for the next one:
for(leti=0;i<10;i++){...}
is not clearer than
for(leti=0;i<=10;i++){...}
It is different code.
for(leti=0;i<11;i++){...}
could be the clearer rewrite of the same code. (Is it though? What's 11?)
The bigger issue there is probably the magic number 10.
Better than any comment you could leave would be extracting it to a named constant. A constant semantically named for the reason it's used there.
These are both good code:
for(leti=0;i<10;i++){...}// BADfor(leti=0;i<=9;i++){...}// BADconstlen=10constlastIndex=len-1for(leti=0;i<len;i++){...}// GOODfor(leti=0;i<=lastIndex;i++){...}// GOOD
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I have a problem with the way Subtle logic errors section is phrased.
is not a clearer way to write
It's different code. Did you mean that a bug was fixed, and not a refactor occured?
Same for the next one:
is not clearer than
It is different code.
could be the clearer rewrite of the same code. (Is it though? What's
11
?)The bigger issue there is probably the magic number
10
.Better than any comment you could leave would be extracting it to a named constant. A constant semantically named for the reason it's used there.
These are both good code: