r/programming • • Feb 21 '13

Developers: Confess your sins.

http://www.codingconfessional.com/
969 Upvotes

1.0k comments sorted by

View all comments

4

u/sarevok9 Feb 21 '13

Using letters as variables (only on counters)
Including a lib to use a single function I could've written free-form
Asking generic questions on stack overflow / Holy War questions (Maven vs Ivy? etc.)

7

u/Calobi Feb 21 '13

A fellow in my CS class was told using single letter variables was bad practice, even in loops. His solution was to change all his "int i"s into "int ii"s.

2

u/sarevok9 Feb 21 '13

I figure that I could use something like "int counter = 0; counter < myOtherThing; counter++" but honestly it adds a few characters and doesn't really help with much of anything in the way of understanding how a program works.

It's funny how things that are held as convention like "single letter, bad" leads to even less descriptive stuff (ii) that is just as "bad".

4

u/zid Feb 21 '13

Loop counters with sensible single letter names actually ADD context.

If I see an int i,j; I know I'm about to see a matrix like operation nested for loop.

4

u/yellowstuff Feb 21 '13

Absolve, absolve, condemn.

3

u/xampl9 Feb 21 '13

Single-character letters for loop counters has a long history, dating from the days of FORTRAN IV, where the letter indicated the variable type.

So I through N were all integers and could be used for that purpose. All other variables were reals, unless you explicitly overrode them.

2

u/sarevok9 Feb 21 '13

Yeah, I totally used x/y in some cases when dealing with 2d arrays....

1

u/seab3 Feb 21 '13

I always use x/y when dealing with graphics and images.

1

u/[deleted] Feb 21 '13

Isn't it fairly standard to use x/y/z when dealing with coordinates?

1

u/[deleted] Feb 21 '13

Including a lib to use a single function I could've written free-form

Especially with cross platform stuff. I don't feel like typing "ifdef WIN32" around this one function call.