
What coding mnemonics do you use? - vickytnz
What weird coding things do you have to use statements for or other weird tricks to remember? I can never remember &lt; or &gt;, and only remember that &lt; is less than from years of typing (i=0; i&lt;30; i++).
======
MichaelAza
Not a mnemonic per se but I have melodies for common code snippets.

"public static void Main(string[] args)", which is the default method
signature for the main method in C#, is a hip-hop beat. SQL statements are
always metal tunes. Javascript is usually indie pop.

~~~
suhailpatel
I also have a melody for the default method signature in Java which is the
same except a slight difference in case "public static void main(String []
args)"

~~~
JonnieCache
Please tell me you guys are actually singing the signature to a particular
tune in your head like people sing the ABC song when they recite the alphabet.
Because that is adorable.

Rapping arbitrary chunks of code could be a fun after-hours conference game.

~~~
MichaelAza
You're partially correct. I do sing them, not necessarily in my head.

------
Terretta
Markdown hyperlink syntax:

    
    
      "squared circle" aka []() aka [word](http://link)

------
hill79
I never remember that . = class and # = id in CSS, so I use "say no to drugs"
to remember that "hash is not class".

Perhaps a mnemonic which only really works in the North East of the UK where
'class' is colloquial slang for 'good'. Also not very good if you smoke pot, I
guess.

~~~
nakkiel
Strange one. FYI, "class" has the same meaning in French slang -- probably
borrowed from you guys.

~~~
scrapcode
I think it's the other way around. I think you guys use _class_ as slang to
_classy_: "pertaining to or characteristic of a (high) class," which comes
from the literal sense of _class_ , which comes from the _French_ word
_classer_.

I didn't know for sure, but I had that feeling knowing that most of the
English language is borrowed from others, and not the other way around.
([http://www.etymonline.com/index.php?allowed_in_frame=0&searc...](http://www.etymonline.com/index.php?allowed_in_frame=0&search=class&searchmode=none))

------
ronaldx
The fact that programmers can't remember < and > 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'

~~~
afandian
I find it hard to believe that a statistically normal programmer mixes up <
and >. That sounds more like dyslexia.

~~~
yogo
This is the first time I'm hearing about this too so I think there is more to
it. I don't even see why a mnemonic is required since the shape of both '<'
and '>' clearly demonstrate the relationship that the operator is testing.

~~~
vickytnz
I probably should have chosen a better mnemonic to start from! I'd point out
that if you see greater and less than more like arrows it's utterly confusing.
I'm not denying I'm probably weird in that respect, it's just something I have
to use tricks to remember….

------
jentulman
LoVe HAte when ordering psudeo classes in css for anchors*

    
    
      ":link, :visited, :hover, :active"
    

*may not be particularly weird or novel

~~~
halisaurus
Also CSS related, when doing margin/padding I use "TRouBLe" to remember:

    
    
        margin: (T R B L)

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

~~~
Someone
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)

------
anotherhue
Questionably coding, but I always loved this IRC snippet:

<sdmkun> tar -xzf merc.tgz what the fuck

<sdmkun> how the fuck do you people remember this shit

<bucketmouse> just think with a german accent

<bucketmouse> XTRACT ZE FILES

~~~
belovedeagle
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

~~~
anotherhue
I quite like it, and have almost a singalong bit for the meaning attached to
each character I add to a long tar command

tar - [create] [verbosely] [a g/bzip'd compressed] [file named] foo.tgz (from)
input_dir

tar -cvzf foo.tgz input_dir

Your version doesn't seem as 'fun', I guess zcat and PIPE are just hard to
rhyme along to.

------
billb2112
I was taught the alligator/crocodile thing like many others, but it never
really stuck. For some reason (later in life), someone said "left hand, less
than" as they held up their left hand to form a less than sign. That image
sticks in my head a lot better.

Another thing that was particularly hard to get naturally was the ternary
operator. It didn't sink in easily until Jon Skeet said pretend the ? is
indeed a question. If the answer is 'yes', this will happen.

------
raverbashing
Not related to programming but close

The symbol for a diode is something like this: --|>|--

Now, which one is the Anode, which one is the Cathode

Very simple, the Anode has an A in the drawing (left side, turned 90 degrees),
the Cathode (K) has a K, right side, upside down in the drawing

------
da02
.unshift - makes it bigger. Longer word than .shift

.shift - makes it smaller. Shorter word than .unshift

~~~
ronaldx
I could _never_ remember this until someone told me to imagine that an array
is like a row of chairs at a cinema.

"Shift" will shift everyone up one, bumping someone off the start of the row.

------
chriswaugh
When working with axis - "X is a-cross"

~~~
Chris2048
" You have to run, before you can fly, You have to X, before you can Y ",

Rhyming reminder of which axis is vertical, and which horizontal...

------
pwg
You might try a visual trick. Note that < and > look like "arrows" and "point"
in a particular direction. There is a small end (the tip/point) and a large
end (the open end). The vertical size of the point is "less than" the vertical
size of open end. So if the point comes first (reading left to right) then the
point is "less than" the opening (and the symbol means "less than"), but if
the opening comes first (reading left to right), the opening is "greater than"
the point (and the symbol means "greater than"). .

~~~
MerreM
Imagine the arrows are crocodiles. They always try and eat more.

1 < 2

4 > 1

If they're eating less, they're not happy crocodiles.

~~~
haliphax
Or the "is greater than" (>) is a crocodile's mouth, and "is less than" (<) is
a bird's beak. The bird eats smaller food than an crocodile eats, and the
crocodile eats bigger food than the bird eats.

------
PaulHoule
< and > are pretty easy. The big side (the mouth) points to the larger number
because that it what it wants to eat.

~~~
raverbashing
I learned this in school. Still effective.

But I never know which one is "smaller than" or "bigger than", I have to think
a little bit

------
CJefferson
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 :)

~~~
belovedeagle
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

------
ChristianMarks
For the right-hand rule, a vile insult: take the cross-product of the thumb
and forefinger of your right hand and rotate on it.

Look, Joshua Foer says that emotional imagery is more likely to stick...

------
anonymous
I don't use mnemonics in general. For me the effort to remember the mnemonic
is actually double that for remembering the thing per se. I need to once
remember the symbols->mnemonic connection and then the mnemonic->meaning
connection, instead of simply the direct symbols->meaning one. It feels like
cluttering my brain with junk that not only doesn't make it easier to remember
things, it actively makes it harder.

------
burgeralarm
When using ln to link files, I tend to recite:

ln -s "what you want," "where you want it"

~~~
lostdog
Another way to remember, is that ln behaves the same as cp

------
3minus1
backslash is a man falling backwards. forwardslash is the opposite.

------
Joeboy
"dollar hat, dollar at" in Makefiles:

$(CC) -c $^ -o $@

------
leigh_t
\r\n or \n\r?

ReturN - R before N

~~~
informatimago
Carriage Return is first because it takes much more time for the carriage to
go back to the column 0 from the column 79, than for the paper to Line Feed
one line. So while the carriage is flying back, the paper can feed, and
hopefully we won't have to wait too much time for everything to be ready for a
new line. Or we may always insert some Nul codes to wait.

