Live data from Hacker News

How to Write Unmaintainable Code – Naming

mindprod.com

1–10 of 43 posts

Re: How to Write Unmaintainable Code – Naming

#2
OP forgot an important tool: store as many variable as possible in one long array. When ever possible use predefined constants like "one," "first," and "superVar" to refer to the index of the desired value in the Array, make sure that all of the above mentioned constants have the same value and are defined in different parts of the code.

Re: How to Write Unmaintainable Code – Naming

#3
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 '*' and matches everything.

Re: How to Write Unmaintainable Code – Naming

#4
My favorite way of doing naming in JavaScript is using ಠ_ಠ as a variable (especially if I need to create some sort of quick "hack" to make some sort of urgent issue go away).

Also fun is using reserved JavaScript keyboards inside of JavaScript objects which, while legal, rarely color correctly in code editors.

Re: How to Write Unmaintainable Code – Naming

#5
post #2

OP forgot an important tool: store as many variable as possible in one long array. When ever possible use predefined constants like "one," "first," and "superVar" to refer to the index of the desired value in the Array, make sure that all of the above mentioned constants have the same value and are defined in different parts of the code.

don't forget tmp, tmp1 and tmp2.

Re: How to Write Unmaintainable Code – Naming

#7
"If anyone even hints at breaking the tradition honoured since FØRTRAN of using i, j and k for indexing variables, namely replacing them with ii, jj and kk, warn them about what the Spanish Inquisition did to heretics."

Hold on, should we use i instead of ii, or not use it? I fucking hate these double-negative articles.

Re: How to Write Unmaintainable Code – Naming

#9
post #7

"If anyone even hints at breaking the tradition honoured since FØRTRAN of using i, j and k for indexing variables, namely replacing them with ii, jj and kk, warn them about what the Spanish Inquisition did to heretics." Hold on, should we use i instead of ii, or not use it? I fucking hate these double-negative articles.

The article is saying not to mess with the "religious" tradition of i/j/k, which means that the author actually things that ii/jj/kk are better. I don't think it's hard to follow, really, unless maybe if English isn't your first language.
Post reply on HN