Each post must contain one bad programming practice to add to the list. I'll start:
In C++, overload library functions by using #define. That way it looks like you are using a familiar library function where in actuality you are using something totally different.
Name:
Anonymous2010-10-19 0:42
putting a { on the same line that a function is declared
Never write comments - good code (that is *my* code) explains itself
Name:
Anonymous2010-10-19 0:49
>>5
good programmers should be able to trace through a program no problem and discover what it's doing without comments, now if you're learning the language then the examples should have them, but unless you're a retad you probably don't need comments k
>>10
Doing that increases the velocidensity of the sector of your hard drive where the file is stored, which in turn means that there will be less velocidensity available for your music files. If you use lossy compression you won't notice the difference, but your FLAC files will gradually lose information.
>>16
Please learn about monoids, thank you. (+) is a natural candidate for the monoidal operation because it is always associative and usually commutative.
Why is sub proc{my @arr=('a','b','c');return @arr};print( (proc())[1] );,
possible, but not sub proc{my %h=('a'=>'b','c'=>'d');return %h};print( (proc()){'a'} );
>>37 no True Programmer uses anything but references.
Refs are a pain in perl5. It's the only time sigil variance causes problems (indirectly) for me. OTOH in Perl 6 refs are implicit most of the time, and during assignment you use the binding operator instead of taking a ref and assigning that.
Single character variable names. I can't believe academics encourage this practice still.
I can think of a lot of Python-specific ones, but I'll limit myself to one case.
class SomeObject (object):
member = OtherObject() #This will hurt you.
Name:
Anonymous2010-10-19 20:48
Using opiates
Name:
Anonymous2010-10-19 20:53
>>48
There's nothing wrong with using i or j as loop variables. It's a widely understood convention, and trying to be clever by calling them something like index will only confuse/piss off other people who have to read your code.
Name:
Anonymous2010-10-19 21:08
EVERYTHING HAS ALREADY BEEN ANSWERED IN >>9
THREAD OVER
Name:
Anonymous2010-10-19 21:26
>>50
No. It will only confuse you if can't handle the extra readability.
>>52
Your code should convey its semantics as clearly as possible. That means choosing familiar idioms whenever you can. The extra 200ms it takes your maintenance programmer to figure out that by int counter you really meant int i are better spent elsewhere.
Writing an HTTP client library and making it impossible to do a simple GET request and put the result into a string in less than 15 lines of code. I'm looking at you, Java.
Not cleaning the cappuccino tube in the coffee machine after yourself. It irritates other programmers in your team and impairs your overall performance.
>>21 it is always associative and usually commutative. + is commutative on every ring. If you're doing calculations on non-ring environtments, you are utterly doomed.
>>79
Thank you! Thank you so much! Oh god, I'm so unprepared. I'd just like to thank The Sussman, HMA meme fan, and of course my anus for all the love and support they've given me over the years. I love you all!
FUQUE, my [b][i]FIBONACCIBUTTSORT[o][/i][/b] algorithm is broken.
Name:
Anonymous2010-10-24 4:29
>>50
I was speaking of something like the following:
for x in elements:
for y in subelements:
...
Or perhaps:
x = y.method_call()
if x > z:
...
I wouldn't mind seeing them used as names for indexes in a C-style for loop. Another good place is in a language construct like a Python generator expression, where names are only used to describe how something should be generated in a single line. SQL aliases are also a good place for names of a very short length.
>>97
Funny, I tend to use i and j in for(;;) loops, but in foreach loops it's usually a (possibly abbreviated) singular form of the name of the array, i.e. for elem in elements.