Slide 1

Slide 1 text

Ruby On Rails coding conventions, standards and best practices David Paluy August 2012

Slide 2

Slide 2 text

Philosophy (from Rails) ● DRY – Don't Repeat Yourself ● Convention over Configuration ● YAGNI - You ain't gonna need it

Slide 3

Slide 3 text

Source code Style ● Two spaces, no tabs ● Boolean tests: don't use “and” and “or”, always use “&&” and “| |”

Slide 4

Slide 4 text

Go Easy on the Comments ● If it's obvious – don't explain it ● Remove old commented code ● “How to” comments

Slide 5

Slide 5 text

Camels for Classes, Snakes Everywhere Else ● “Snake case”: lowercasse_words_separated_by_underscore ● “Camel case”: ClassName good Class_name bad ● Constants: (my own preference) ALL_UPPERCASE = true

Slide 6

Slide 6 text

Parentheses (Optional)

Slide 7

Slide 7 text

Parentheses (Do & Don't)

Slide 8

Slide 8 text

Folding Up Lines

Slide 9

Slide 9 text

Folding Up Blocks

Slide 10

Slide 10 text

if vs unless

Slide 11

Slide 11 text

while vs until

Slide 12

Slide 12 text

Use Modifier Forms

Slide 13

Slide 13 text

each, NOT for

Slide 14

Slide 14 text

In the Wild

Slide 15

Slide 15 text

Use Symbols to Stand for Something

Slide 16

Slide 16 text

Composing Methods for Humans

Slide 17

Slide 17 text

Make the code a little more articulate

Slide 18

Slide 18 text

Readable Code

Slide 19

Slide 19 text

Readable code makes your classes easier to test

Slide 20

Slide 20 text

Git the diff says what you did; your commit message should tell me why you did this

Slide 21

Slide 21 text

Summary Good code is like a good joke: It needs no explanation

Slide 22

Slide 22 text

Credentials