SlideShare a Scribd company logo
Ruby On Rails coding
 conventions, standards
   and best practices

David Paluy
August 2012
Philosophy (from Rails)

●   DRY – Don't Repeat Yourself

●   Convention over Configuration

●   YAGNI - You ain't gonna need it
Source code Style

●   Two spaces, no tabs
●   Boolean tests:
    don't use “and” and “or”,
    always use “&&” and “| |”
Go Easy on the Comments

●   If it's obvious – don't explain it
●   Remove old commented code
●   “How to” comments
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
Parentheses (Optional)
Parentheses (Do & Don't)
Folding Up Lines
Folding Up Blocks
if vs unless
while vs until
Use Modifier Forms
each, NOT for
In the Wild
Use Symbols to Stand for Something
Composing Methods for Humans
Make the code a little more articulate
Readable Code
Readable code makes your
  classes easier to test
Git

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



Good code is like a good joke:

  It needs no explanation
Credentials
Ad

Recommended

Interação Humano Computador Capítulo 11 - Análise de Atividades
Interação Humano Computador Capítulo 11 - Análise de Atividades
Wellington Oliveira
 
Radiografias extrabucais.pptx
Radiografias extrabucais.pptx
ceciliamonteiro12
 
Apresentação TCC - Banca
Apresentação TCC - Banca
guest2c4508
 
TUMORES odontogênicos.pdf
TUMORES odontogênicos.pdf
Elissandra Menezes
 
Aula 4 - Avaliação de Interface - Parte 1
Aula 4 - Avaliação de Interface - Parte 1
André Constantino da Silva
 
Mapas de site, Fluxos de Tarefa, Wireframe e Prototipagem
Mapas de site, Fluxos de Tarefa, Wireframe e Prototipagem
Ros Galabo, PhD
 
Lista de exercicios de sig (respondida) 1bimestre 2013
Lista de exercicios de sig (respondida) 1bimestre 2013
José Nascimento
 
Norma lateral de Ricketts
Norma lateral de Ricketts
Tábitha Olicshevis
 
Ruby on rails. Best practices
Ruby on rails. Best practices
Vladimir Tkach
 
Rails Best Practices
Rails Best Practices
Icalia Labs
 
Principles of MVC for Rails Developers
Principles of MVC for Rails Developers
Edureka!
 
Rails Best Practices
Rails Best Practices
Wen-Tien Chang
 
walkmod: An open source tool for coding conventions
walkmod: An open source tool for coding conventions
walkmod
 
AngularJS Best Practices
AngularJS Best Practices
Betclic Everest Group Tech Team
 
Railsチュートリアルの歩き方 (第4版)
Railsチュートリアルの歩き方 (第4版)
Yohei Yasukawa
 
Secure Your REST API (The Right Way)
Secure Your REST API (The Right Way)
Stormpath
 
Write your Ruby in Style
Write your Ruby in Style
Bhavin Javia
 
Java Coding Conventions
Java Coding Conventions
Rodel Barcenas
 
Writing Good Code
Writing Good Code
Leo Liang
 
C# conventions & good practices
C# conventions & good practices
Tan Tran
 
Coding standards
Coding standards
BishalAryal8
 
Coding standards
Coding standards
Mimoh Ojha
 
Java code conventions
Java code conventions
Armando Daniel
 
CodeConventions.pdf
CodeConventions.pdf
Jeff Smith
 
Naming Things (with notes)
Naming Things (with notes)
Pete Nicholls
 
Coding conventions
Coding conventions
systemcrashed
 
Code conventions
Code conventions
Hermano Portes
 
Documenting code yapceu2016
Documenting code yapceu2016
Søren Lund
 
Clean Code
Clean Code
Chris Farrell
 
Best coding practices
Best coding practices
baabtra.com - No. 1 supplier of quality freshers
 

More Related Content

Viewers also liked (8)

Ruby on rails. Best practices
Ruby on rails. Best practices
Vladimir Tkach
 
Rails Best Practices
Rails Best Practices
Icalia Labs
 
Principles of MVC for Rails Developers
Principles of MVC for Rails Developers
Edureka!
 
Rails Best Practices
Rails Best Practices
Wen-Tien Chang
 
walkmod: An open source tool for coding conventions
walkmod: An open source tool for coding conventions
walkmod
 
AngularJS Best Practices
AngularJS Best Practices
Betclic Everest Group Tech Team
 
Railsチュートリアルの歩き方 (第4版)
Railsチュートリアルの歩き方 (第4版)
Yohei Yasukawa
 
Secure Your REST API (The Right Way)
Secure Your REST API (The Right Way)
Stormpath
 
Ruby on rails. Best practices
Ruby on rails. Best practices
Vladimir Tkach
 
Rails Best Practices
Rails Best Practices
Icalia Labs
 
Principles of MVC for Rails Developers
Principles of MVC for Rails Developers
Edureka!
 
walkmod: An open source tool for coding conventions
walkmod: An open source tool for coding conventions
walkmod
 
Railsチュートリアルの歩き方 (第4版)
Railsチュートリアルの歩き方 (第4版)
Yohei Yasukawa
 
Secure Your REST API (The Right Way)
Secure Your REST API (The Right Way)
Stormpath
 

Similar to Ruby On Rails coding conventions, standards and best practices (20)

Write your Ruby in Style
Write your Ruby in Style
Bhavin Javia
 
Java Coding Conventions
Java Coding Conventions
Rodel Barcenas
 
Writing Good Code
Writing Good Code
Leo Liang
 
C# conventions & good practices
C# conventions & good practices
Tan Tran
 
Coding standards
Coding standards
BishalAryal8
 
Coding standards
Coding standards
Mimoh Ojha
 
Java code conventions
Java code conventions
Armando Daniel
 
CodeConventions.pdf
CodeConventions.pdf
Jeff Smith
 
Naming Things (with notes)
Naming Things (with notes)
Pete Nicholls
 
Coding conventions
Coding conventions
systemcrashed
 
Code conventions
Code conventions
Hermano Portes
 
Documenting code yapceu2016
Documenting code yapceu2016
Søren Lund
 
Clean Code
Clean Code
Chris Farrell
 
Best coding practices
Best coding practices
baabtra.com - No. 1 supplier of quality freshers
 
Best Practices For Writing Super Readable Code
Best Practices For Writing Super Readable Code
AnsviaLab
 
Clean code
Clean code
Nascenia IT
 
Principled And Clean Coding
Principled And Clean Coding
Metin Ogurlu
 
Java convention
Java convention
Tan Tran
 
Code Conventions
Code Conventions
provadaordem
 
Ruby on Rails Presentation
Ruby on Rails Presentation
adamcookeuk
 
Write your Ruby in Style
Write your Ruby in Style
Bhavin Javia
 
Java Coding Conventions
Java Coding Conventions
Rodel Barcenas
 
Writing Good Code
Writing Good Code
Leo Liang
 
C# conventions & good practices
C# conventions & good practices
Tan Tran
 
Coding standards
Coding standards
Mimoh Ojha
 
CodeConventions.pdf
CodeConventions.pdf
Jeff Smith
 
Naming Things (with notes)
Naming Things (with notes)
Pete Nicholls
 
Documenting code yapceu2016
Documenting code yapceu2016
Søren Lund
 
Best Practices For Writing Super Readable Code
Best Practices For Writing Super Readable Code
AnsviaLab
 
Principled And Clean Coding
Principled And Clean Coding
Metin Ogurlu
 
Java convention
Java convention
Tan Tran
 
Ruby on Rails Presentation
Ruby on Rails Presentation
adamcookeuk
 
Ad

More from David Paluy (15)

Intro to Smart Contracts
Intro to Smart Contracts
David Paluy
 
Decentralizing Everything with Blockchain
Decentralizing Everything with Blockchain
David Paluy
 
Testing with Rspec 3
Testing with Rspec 3
David Paluy
 
Continuous integration for Ruby on Rails
Continuous integration for Ruby on Rails
David Paluy
 
Tdd - Test Driven Development
Tdd - Test Driven Development
David Paluy
 
Knowledge sharing at MESH
Knowledge sharing at MESH
David Paluy
 
Juicy Ruby 2.1
Juicy Ruby 2.1
David Paluy
 
The Secret: How Programmers Develop Code
The Secret: How Programmers Develop Code
David Paluy
 
Tools to help you understand other people's code
Tools to help you understand other people's code
David Paluy
 
Debugging and Profiling Rails Application
Debugging and Profiling Rails Application
David Paluy
 
Security on Rails
Security on Rails
David Paluy
 
Git flow Introduction
Git flow Introduction
David Paluy
 
Faster on Rails
Faster on Rails
David Paluy
 
Howto prepare fund raising presentation
Howto prepare fund raising presentation
David Paluy
 
Test driven-development
Test driven-development
David Paluy
 
Intro to Smart Contracts
Intro to Smart Contracts
David Paluy
 
Decentralizing Everything with Blockchain
Decentralizing Everything with Blockchain
David Paluy
 
Testing with Rspec 3
Testing with Rspec 3
David Paluy
 
Continuous integration for Ruby on Rails
Continuous integration for Ruby on Rails
David Paluy
 
Tdd - Test Driven Development
Tdd - Test Driven Development
David Paluy
 
Knowledge sharing at MESH
Knowledge sharing at MESH
David Paluy
 
The Secret: How Programmers Develop Code
The Secret: How Programmers Develop Code
David Paluy
 
Tools to help you understand other people's code
Tools to help you understand other people's code
David Paluy
 
Debugging and Profiling Rails Application
Debugging and Profiling Rails Application
David Paluy
 
Security on Rails
Security on Rails
David Paluy
 
Git flow Introduction
Git flow Introduction
David Paluy
 
Howto prepare fund raising presentation
Howto prepare fund raising presentation
David Paluy
 
Test driven-development
Test driven-development
David Paluy
 
Ad

Recently uploaded (6)

The Anxious Generation Summary: How Digital Upheaval Is Damaging Youth Mental...
The Anxious Generation Summary: How Digital Upheaval Is Damaging Youth Mental...
MohammedTouzani2
 
Personal Safety for Women - 12 Reasons Why Women Stay in An Abusive Relations...
Personal Safety for Women - 12 Reasons Why Women Stay in An Abusive Relations...
Robert Kaiser
 
Psychosocial support activity emotion space.pptx
Psychosocial support activity emotion space.pptx
AnnaMae39
 
Extended_Colorful_Presentation_with_Icons.pptx
Extended_Colorful_Presentation_with_Icons.pptx
w6pvzbjp7m
 
KK KLUB
KK KLUB
zukkunft
 
Rewire Your Day: 10 Everyday Biohacks for Energy, Clarity, and Empowerment
Rewire Your Day: 10 Everyday Biohacks for Energy, Clarity, and Empowerment
cathassistservice
 
The Anxious Generation Summary: How Digital Upheaval Is Damaging Youth Mental...
The Anxious Generation Summary: How Digital Upheaval Is Damaging Youth Mental...
MohammedTouzani2
 
Personal Safety for Women - 12 Reasons Why Women Stay in An Abusive Relations...
Personal Safety for Women - 12 Reasons Why Women Stay in An Abusive Relations...
Robert Kaiser
 
Psychosocial support activity emotion space.pptx
Psychosocial support activity emotion space.pptx
AnnaMae39
 
Extended_Colorful_Presentation_with_Icons.pptx
Extended_Colorful_Presentation_with_Icons.pptx
w6pvzbjp7m
 
Rewire Your Day: 10 Everyday Biohacks for Energy, Clarity, and Empowerment
Rewire Your Day: 10 Everyday Biohacks for Energy, Clarity, and Empowerment
cathassistservice
 

Ruby On Rails coding conventions, standards and best practices