Live data from Hacker News

What coding mnemonics do you use?

news.ycombinator.com

61–70 of 88 posts

Re: What coding mnemonics do you use?

#63
post #43
post #38

Earlier quoted context omitted.

I find it hard to believe that someone actually mixes these unless they completely skipped all math classes in school.

I remember several kids in my class having great difficulty with when they were first introduced. I can well imagine many of them just decided it was impossible and gave up.

Was it possible to give up? In my place, they wouldn't be let on to the next grade if they'd fail basic math - i.e., they'd spend the summer repeating it + an extra year in the same grade if that wasn't enough; so it would have to be a real exception to see a 10 year old who can't somehow manage that.

Anyways, the classic mnemonic for that was simple - for the wide part contains more 'thingies' than the narrow part. They're actually taught before numbers or together with numbers, like [pic of four strawberries] > [pic of three strawberries].

Re: What coding mnemonics do you use?

#64

Most methods in C read like an assignment, so if you are trying to remember what order the arguments to strcpy go, it's strcpy(x,y) is like x = y Then remember specially that typedef is the wrong way around to the way you would like it to be :)

The trick with typedef is it is exactly the same syntax, in all cases, as declaring a variable of that type. This is essentially the only way you're going to ever remember how to do function pointer typedefs: typedef int (function_t)(int,int); // or something to that effect

Re: What coding mnemonics do you use?

#65

Questionably coding, but I always loved this IRC snippet: tar -xzf merc.tgz what the fuck how the fuck do you people remember this shit just think with a german accent XTRACT ZE FILES

I really don't see what the big deal is with tar. Everyone seems to hate it. Probably because exactly one of those flags is necessary: zcat merc.tgz | tar -x

Re: What coding mnemonics do you use?

#66

Earlier quoted context omitted.

Also CSS related, when doing margin/padding I use "TRouBLe" to remember: margin: (T R B L)

My one is visualising a clock face, 12, 3, 6, 9

Thats a nice example showing that mnemonics need not be logical to have value (if you asked people to order the numbers on a clock face, I think the vast majority would have them as 3, 6, 9, 12)

Re: What coding mnemonics do you use?

#68
post #28

The fact that programmers can't remember well illustrates why children shouldn't be chastised for getting (for example) b and d wrong. I have dealt with this by conditioning myself to always read < as 'is less than'

When I was in grad school a friend in another department said "You guys in CS have much nicer printers; can I mail you my thesis and have you print it out? And how would I mail it?" I said "Sure; Just do 'mail me@school.edu less-than-symbol filename". Later he calls in a panic -- "my thesis file has disappeared! I did what you said ... oh, wait a minute, I might have done greater-than instead of less-than..."

Fortunately for both of us, he had been diligent about making backups and din't lose his entire thesis.

Re: What coding mnemonics do you use?

#70
post #38
post #36

Earlier quoted context omitted.

I was surprised to see that as an example as well, but then I thought back to starting out as a programmer. I'm sure I spent many hours fixing bugs caused by getting wrong.

I find it hard to believe that someone actually mixes these unless they completely skipped all math classes in school.

I was taught the crocodile thing, but had real issues with it: I can think it through but it's not fast. I'm pretty much ambidexterous (i.e. write with left and catch a ball with my right) so while I can do quite a lot of things with both hands I also have problems with left and right!
Post reply on HN