SlideShare a Scribd company logo
1 of 22
Download to read offline
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

More Related Content

What's hot

Quine・難解プログラミングについて
Quine・難解プログラミングについてQuine・難解プログラミングについて
Quine・難解プログラミングについてmametter
 
Policy Gradient Theorem
Policy Gradient TheoremPolicy Gradient Theorem
Policy Gradient TheoremAshwin Rao
 
SECDマシン 実装と動きとその他もろもろについて
SECDマシン 実装と動きとその他もろもろについてSECDマシン 実装と動きとその他もろもろについて
SECDマシン 実装と動きとその他もろもろについてt-sin
 
Chapter 15 Representation learning - 1
Chapter 15 Representation learning - 1Chapter 15 Representation learning - 1
Chapter 15 Representation learning - 1KyeongUkJang
 
.NET Core 3.0時代のメモリ管理
.NET Core 3.0時代のメモリ管理.NET Core 3.0時代のメモリ管理
.NET Core 3.0時代のメモリ管理KageShiron
 
가깝고도 먼 Trpo
가깝고도 먼 Trpo가깝고도 먼 Trpo
가깝고도 먼 TrpoWoong won Lee
 
Proposal For Corporate Cleaning Services PowerPoint Presentation Slides
Proposal For Corporate Cleaning Services PowerPoint Presentation SlidesProposal For Corporate Cleaning Services PowerPoint Presentation Slides
Proposal For Corporate Cleaning Services PowerPoint Presentation SlidesSlideTeam
 

What's hot (7)

Quine・難解プログラミングについて
Quine・難解プログラミングについてQuine・難解プログラミングについて
Quine・難解プログラミングについて
 
Policy Gradient Theorem
Policy Gradient TheoremPolicy Gradient Theorem
Policy Gradient Theorem
 
SECDマシン 実装と動きとその他もろもろについて
SECDマシン 実装と動きとその他もろもろについてSECDマシン 実装と動きとその他もろもろについて
SECDマシン 実装と動きとその他もろもろについて
 
Chapter 15 Representation learning - 1
Chapter 15 Representation learning - 1Chapter 15 Representation learning - 1
Chapter 15 Representation learning - 1
 
.NET Core 3.0時代のメモリ管理
.NET Core 3.0時代のメモリ管理.NET Core 3.0時代のメモリ管理
.NET Core 3.0時代のメモリ管理
 
가깝고도 먼 Trpo
가깝고도 먼 Trpo가깝고도 먼 Trpo
가깝고도 먼 Trpo
 
Proposal For Corporate Cleaning Services PowerPoint Presentation Slides
Proposal For Corporate Cleaning Services PowerPoint Presentation SlidesProposal For Corporate Cleaning Services PowerPoint Presentation Slides
Proposal For Corporate Cleaning Services PowerPoint Presentation Slides
 

Viewers also liked

Ruby on rails. Best practices
Ruby on rails. Best practicesRuby on rails. Best practices
Ruby on rails. Best practicesVladimir Tkach
 
Rails Best Practices
Rails Best PracticesRails Best Practices
Rails Best PracticesIcalia Labs
 
Principles of MVC for Rails Developers
Principles of MVC for Rails DevelopersPrinciples of MVC for Rails Developers
Principles of MVC for Rails DevelopersEdureka!
 
walkmod: An open source tool for coding conventions
walkmod: An open source tool for coding conventionswalkmod: An open source tool for coding conventions
walkmod: An open source tool for coding conventionswalkmod
 
Railsチュートリアルの歩き方 (第4版)
Railsチュートリアルの歩き方 (第4版)Railsチュートリアルの歩き方 (第4版)
Railsチュートリアルの歩き方 (第4版)Yohei Yasukawa
 
Secure Your REST API (The Right Way)
Secure Your REST API (The Right Way)Secure Your REST API (The Right Way)
Secure Your REST API (The Right Way)Stormpath
 

Viewers also liked (8)

Ruby on rails. Best practices
Ruby on rails. Best practicesRuby on rails. Best practices
Ruby on rails. Best practices
 
Rails Best Practices
Rails Best PracticesRails Best Practices
Rails Best Practices
 
Principles of MVC for Rails Developers
Principles of MVC for Rails DevelopersPrinciples of MVC for Rails Developers
Principles of MVC for Rails Developers
 
Rails Best Practices
Rails Best PracticesRails Best Practices
Rails Best Practices
 
walkmod: An open source tool for coding conventions
walkmod: An open source tool for coding conventionswalkmod: An open source tool for coding conventions
walkmod: An open source tool for coding conventions
 
AngularJS Best Practices
AngularJS Best PracticesAngularJS Best Practices
AngularJS Best Practices
 
Railsチュートリアルの歩き方 (第4版)
Railsチュートリアルの歩き方 (第4版)Railsチュートリアルの歩き方 (第4版)
Railsチュートリアルの歩き方 (第4版)
 
Secure Your REST API (The Right Way)
Secure Your REST API (The Right Way)Secure Your REST API (The Right Way)
Secure Your REST API (The Right Way)
 

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

Best practices for JavaScript RIAs
Best practices for JavaScript RIAsBest practices for JavaScript RIAs
Best practices for JavaScript RIAsCarlos Ble
 
Hardcore JavaScript – Write it Right
Hardcore JavaScript – Write it RightHardcore JavaScript – Write it Right
Hardcore JavaScript – Write it RightMike Wilcox
 
Rails Development That Doesn't Hurt
Rails Development That Doesn't HurtRails Development That Doesn't Hurt
Rails Development That Doesn't HurtAkira Matsuda
 
Principled And Clean Coding
Principled And Clean CodingPrincipled And Clean Coding
Principled And Clean CodingMetin Ogurlu
 
TDD - Test Driven Development
TDD - Test Driven DevelopmentTDD - Test Driven Development
TDD - Test Driven DevelopmentTung Nguyen Thanh
 
AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLE
AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLEAN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLE
AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLEGavin Pickin
 
AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLE - CFObjective() 2017
AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLE - CFObjective() 2017AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLE - CFObjective() 2017
AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLE - CFObjective() 2017Ortus Solutions, Corp
 
Good coding-style, a talk made in 2008 to encourage changes in MySQL coding s...
Good coding-style, a talk made in 2008 to encourage changes in MySQL coding s...Good coding-style, a talk made in 2008 to encourage changes in MySQL coding s...
Good coding-style, a talk made in 2008 to encourage changes in MySQL coding s...Kostja Osipov
 
Writing Readable Code
Writing Readable CodeWriting Readable Code
Writing Readable Codeeddiehaber
 
TDD in Python With Pytest
TDD in Python With PytestTDD in Python With Pytest
TDD in Python With PytestEddy Reyes
 
Grooming with Groovy
Grooming with GroovyGrooming with Groovy
Grooming with GroovyDhaval Dalal
 

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

Clean code
Clean codeClean code
Clean code
 
Clean code
Clean codeClean code
Clean code
 
Best practices for JavaScript RIAs
Best practices for JavaScript RIAsBest practices for JavaScript RIAs
Best practices for JavaScript RIAs
 
Hardcore JavaScript – Write it Right
Hardcore JavaScript – Write it RightHardcore JavaScript – Write it Right
Hardcore JavaScript – Write it Right
 
Rails Development That Doesn't Hurt
Rails Development That Doesn't HurtRails Development That Doesn't Hurt
Rails Development That Doesn't Hurt
 
Principled And Clean Coding
Principled And Clean CodingPrincipled And Clean Coding
Principled And Clean Coding
 
TDD - Test Driven Development
TDD - Test Driven DevelopmentTDD - Test Driven Development
TDD - Test Driven Development
 
C# Good practices
C# Good practicesC# Good practices
C# Good practices
 
Clean code coding like a professional
Clean code   coding like a professionalClean code   coding like a professional
Clean code coding like a professional
 
AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLE
AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLEAN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLE
AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLE
 
AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLE - CFObjective() 2017
AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLE - CFObjective() 2017AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLE - CFObjective() 2017
AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLE - CFObjective() 2017
 
C# Best Practices
C# Best PracticesC# Best Practices
C# Best Practices
 
Good coding-style, a talk made in 2008 to encourage changes in MySQL coding s...
Good coding-style, a talk made in 2008 to encourage changes in MySQL coding s...Good coding-style, a talk made in 2008 to encourage changes in MySQL coding s...
Good coding-style, a talk made in 2008 to encourage changes in MySQL coding s...
 
Writing Readable Code
Writing Readable CodeWriting Readable Code
Writing Readable Code
 
클린 테스트
클린 테스트클린 테스트
클린 테스트
 
CLEAN WEB
CLEAN WEBCLEAN WEB
CLEAN WEB
 
TDD in Python With Pytest
TDD in Python With PytestTDD in Python With Pytest
TDD in Python With Pytest
 
Testing gone-right
Testing gone-rightTesting gone-right
Testing gone-right
 
Grooming with Groovy
Grooming with GroovyGrooming with Groovy
Grooming with Groovy
 

More from David Paluy

Intro to Smart Contracts
Intro to Smart ContractsIntro to Smart Contracts
Intro to Smart ContractsDavid Paluy
 
Decentralizing Everything with Blockchain
Decentralizing Everything with BlockchainDecentralizing Everything with Blockchain
Decentralizing Everything with BlockchainDavid Paluy
 
Testing with Rspec 3
Testing with Rspec 3Testing with Rspec 3
Testing with Rspec 3David Paluy
 
Continuous integration for Ruby on Rails
Continuous integration for Ruby on RailsContinuous integration for Ruby on Rails
Continuous integration for Ruby on RailsDavid Paluy
 
Tdd - Test Driven Development
Tdd - Test Driven DevelopmentTdd - Test Driven Development
Tdd - Test Driven DevelopmentDavid Paluy
 
Knowledge sharing at MESH
Knowledge sharing at MESHKnowledge sharing at MESH
Knowledge sharing at MESHDavid Paluy
 
The Secret: How Programmers Develop Code
The Secret: How Programmers Develop CodeThe Secret: How Programmers Develop Code
The Secret: How Programmers Develop CodeDavid Paluy
 
Tools to help you understand other people's code
Tools to help you understand other people's codeTools to help you understand other people's code
Tools to help you understand other people's codeDavid Paluy
 
Debugging and Profiling Rails Application
Debugging and Profiling Rails ApplicationDebugging and Profiling Rails Application
Debugging and Profiling Rails ApplicationDavid Paluy
 
Security on Rails
Security on RailsSecurity on Rails
Security on RailsDavid Paluy
 
Git flow Introduction
Git flow IntroductionGit flow Introduction
Git flow IntroductionDavid Paluy
 
Howto prepare fund raising presentation
Howto prepare fund raising presentationHowto prepare fund raising presentation
Howto prepare fund raising presentationDavid Paluy
 
Test driven-development
Test driven-developmentTest driven-development
Test driven-developmentDavid Paluy
 

More from David Paluy (15)

Intro to Smart Contracts
Intro to Smart ContractsIntro to Smart Contracts
Intro to Smart Contracts
 
Decentralizing Everything with Blockchain
Decentralizing Everything with BlockchainDecentralizing Everything with Blockchain
Decentralizing Everything with Blockchain
 
Testing with Rspec 3
Testing with Rspec 3Testing with Rspec 3
Testing with Rspec 3
 
Continuous integration for Ruby on Rails
Continuous integration for Ruby on RailsContinuous integration for Ruby on Rails
Continuous integration for Ruby on Rails
 
Tdd - Test Driven Development
Tdd - Test Driven DevelopmentTdd - Test Driven Development
Tdd - Test Driven Development
 
Knowledge sharing at MESH
Knowledge sharing at MESHKnowledge sharing at MESH
Knowledge sharing at MESH
 
Juicy Ruby 2.1
Juicy Ruby 2.1Juicy Ruby 2.1
Juicy Ruby 2.1
 
The Secret: How Programmers Develop Code
The Secret: How Programmers Develop CodeThe Secret: How Programmers Develop Code
The Secret: How Programmers Develop Code
 
Tools to help you understand other people's code
Tools to help you understand other people's codeTools to help you understand other people's code
Tools to help you understand other people's code
 
Debugging and Profiling Rails Application
Debugging and Profiling Rails ApplicationDebugging and Profiling Rails Application
Debugging and Profiling Rails Application
 
Security on Rails
Security on RailsSecurity on Rails
Security on Rails
 
Git flow Introduction
Git flow IntroductionGit flow Introduction
Git flow Introduction
 
Faster on Rails
Faster on RailsFaster on Rails
Faster on Rails
 
Howto prepare fund raising presentation
Howto prepare fund raising presentationHowto prepare fund raising presentation
Howto prepare fund raising presentation
 
Test driven-development
Test driven-developmentTest driven-development
Test driven-development
 

Ruby On Rails coding conventions, standards and best practices