4 ms·
When unsigned three = 1; is accompanied by unsigned five = 5; unsigned seven = 7; what would be the sane conclusion?
by tremon 6y ago
When
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).
- jfengel 6y agoAnd then, having located that comment, try to rename the variable to something more meaningful. Even gap1, gap2, and gap3 would be more informative.
- klyrs 6y agoWe have a difference of opinion here. I lean away from bikeshedding in favor of finding more substantive issues. I'm also an old-timer and I'd call this a 3, on a scale from 1 (easily readable code) to 10 (a suitable IOCCC entry)
- jfengel 6y agoIt's also true that unless I had a specific mandate to touch that code, I wouldn't. If nothing else it confuses the commit history, obscuring what I was actually in there to do. But if it were my job to touch these lines of code, I would want to leave them better than I found them.