5 ms·
Not really. Nobody sane would think other sane developer with any expeirience would call a simple variable according to what it initially contains. You'd expect
by scotty79 6y ago
Not really. Nobody sane would think other sane developer with any expeirience would call a simple variable according to what it initially contains. You'd expect either name related to what is the meaning of the contents, or meaningless name.
- oji0hub 6y agoPeople make typos and simple mistakes all the time, regardless of experience.
- Guthur 6y ago+1 seen it so many times, often times from some cut and paste heavy refactor, one is more or less going on autopilot just moving substrings around and then bam. Review process hopefully catches it, when it is a bug, and potentially when the semantics are unclear...
- scotty79 6y agoTrue. But the intention of writing int three = 3; is insane. I would never ascribe to previous programmer (unless he just learned what variables are) the intention of creating variable (not even constant, which wouldn't make it any better) named 'three' and assigning actual value 3 to it.
- forgottenlogin9 6y agoIf that is insane, you may not have issue with this specific line but you surely have issue with the 2 “insane” lines that follow it?
- esrauch 6y agoAll three lines would be "insane" if the variables weren't mutated. As in a variable named "three" is insane if it solely contains either of the values 1 or 3. When it contains other values it is still subpar variable naming.
- scotty79 6y agoIf something looks insane, but probablu sane person made it and it works then that's usually good indicator that you are missing part of the picture and should look around. It still might be bad, but probably not insane.
- tremon 6y agoWhen unsigned three = 1; is accompanied by unsigned five = 5; unsigned seven = 7; what would be the sane conclusion?
- megous 6y agoThese are variables that will change anyway, so the initial values are probably not that relevant to their name?
- magicalhippo 6y agoIn which case the names should be cnt0, cnt1, cnt2 or something along those lines.
- marcosdumay 6y agoThat the code was edited more than once on its lifetime, and in one of those times (not the last one), by someone with pretty bad naming habits.
- scotty79 6y agoThat there are some entities (maybe ordered, maybe related to numbers three, five and seven in some way) and there are some values associated with those entities, two of which (accidentally or not) need to be initially set to corresponding number, but the third one possibly not, but better look around in the comments or code to understand and make sure the code is correct. Then maybe leave a comment right after `= 1;` why this variable shouldn't be initialized with 3 that would clear up confusion for you if it was there.
- klyrs 6y agoThe reasonable conclusion is that you should read the surrounding context and try to understand what these variables are used for. The purpose of code review is to understand the code enough that you can spot real bugs; I try to avoid flagging surface-level stuff unless it's really important. IMO, this is a borderline case due to the very clear comment (which is a bit too far away).