Live data from Hacker News

How to Write Unmaintainable Code – Naming

mindprod.com

11–20 of 43 posts

Re: How to Write Unmaintainable Code – Naming

#11
When 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;”)

Re: How to Write Unmaintainable Code – Naming

#12
post #11

When 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;”)

Why not \u0069\u006e\u0074\u0020\u0069\u0020\u003d\u0020\u0031\u003b ?

Re: How to Write Unmaintainable Code – Naming

#14
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.

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 there.

Re: How to Write Unmaintainable Code – Naming

#15
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.

Python: put everything in a list, then insert it into itself on multiple positions. Then go nuts using slice syntax. Occasionally use hex or octal numbers.

Re: How to Write Unmaintainable Code – Naming

#16
post #15
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.

Python: put everything in a list, then insert it into itself on multiple positions. Then go nuts using slice syntax. Occasionally use hex or octal numbers.

You monster

Re: How to Write Unmaintainable Code – Naming

#17
I once worked on a project where every class was named after a martial arts weapon. As cute as that might have seemed, I quickly grew tired of asking questions like, "Should I be using the Shuriken or the Wazikashi here?"

We ended up scrapping that code and doing a ground-up rewrite.

Re: How to Write Unmaintainable Code – Naming

#19

Earlier quoted context omitted.

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.

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

#20
post #11

When 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;”)

It's important to use this sparingly. When grepping is obviously broken, the adversary will adapt, most likely by writing a script to rewrite the Unicode, then it's back to business as usual.

On the other hand, if grep has a 95% success rate, the adversary may well never notice, and build his or her mental model of the program on flawed understanding. That's when the real fun begins.

Post reply on HN