In the interest of fairness, and in regards to the "Underscore, a friend indeed", I'll point to the existence of eg, $_ and @_ as built-in Perl magic variables (you can get away with not using $_, but not @_). I have also been know to use _ for a variable I will not use later (eg, if a function returns two values but I'm only interested in one). Additionally, in languages with pattern matching, '_' usually works like…
How to Write Unmaintainable Code – Naming
21–30 of 43 posts
Re: How to Write Unmaintainable Code – Naming
#22----------------------------------------------- Use accented characters on variable names, e. g. --typedef struct { int i; } ínt; where the second ínt’s í is actually i-acute. With only a simple text editor, it’s nearly impossible to distinguish the slant of the accent mark.
Re: How to Write Unmaintainable Code – Naming
#23Earlier quoted context omitted.
This is a weird one. Using i,j,k for loop values is fine, especially tight inner loops. I can't see that ii,jj,kk adds anything. And I don't see much point in using verbose names like innerLoopIterator or arrayIdx or whatnot for these type of variables either. Actually later on in rule 20 he implies (with negative logic of course) that i is actually a good inner loop variable name. So that's an inconsistency right th…
ii, jj, and kk, are easier to search for (although I have jj mapped to in vim...) index, jndex, and kndex, are preferred, obviously.
Re: How to Write Unmaintainable Code – Naming
#24http://stackoverflow.com/questions/29696768/which-emoji-can-...
Re: How to Write Unmaintainable Code – Naming
#25Re: How to Write Unmaintainable Code – Naming
#26Remember with unicode support for variable names you can use emoji: http://stackoverflow.com/questions/29696768/which-emoji-can-...
Re: How to Write Unmaintainable Code – Naming
#27Earlier quoted context omitted.
ii, jj, and kk, are easier to search for (although I have jj mapped to in vim...) index, jndex, and kndex, are preferred, obviously.
jj = changed my life; I'm not even joking. I even went so far as to put my zsh in vi mode and added jj there too. (WARNING: doing this will result in a pathological need to type jjk whenever you open a shell to start scrolling through history.)
Re: How to Write Unmaintainable Code – Naming
#28Earlier quoted context omitted.
jj = changed my life; I'm not even joking. I even went so far as to put my zsh in vi mode and added jj there too. (WARNING: doing this will result in a pathological need to type jjk whenever you open a shell to start scrolling through history.)
I prefer mapping to . Hitting single keystroke. I quickly got tired of hitting 'jj' every time I need to escape.
Re: How to Write Unmaintainable Code – Naming
#29Earlier quoted context omitted.
This is a weird one. Using i,j,k for loop values is fine, especially tight inner loops. I can't see that ii,jj,kk adds anything. And I don't see much point in using verbose names like innerLoopIterator or arrayIdx or whatnot for these type of variables either. Actually later on in rule 20 he implies (with negative logic of course) that i is actually a good inner loop variable name. So that's an inconsistency right th…
ii, jj, and kk, are easier to search for (although I have jj mapped to in vim...) index, jndex, and kndex, are preferred, obviously.
I mean - I don't recall writing a loop longer than 2 screens in years. Usually a loop is less than half a screen long.
And anyway, you can search for [^\w]i[^\w] if you really need to.
Maybe it's aquired taste, but in array-heavy code (usually math-related) I much prefer A[i][j][k] * B[j][k][i] than the same with long names for index variables.
Re: How to Write Unmaintainable Code – Naming
#30When you need to prevent quick grepping in Java, you can also take advantage of the fact that unicode escapes can occur everywhere in a java file, not only within quotes. So you can declare an int by writing “\u0069\u006e\u0074 \u0069 = 1;” (equivalent to “int i = 1;”)