Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Ten Commandments of the Ruby Programmer
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Emilio Gutter
October 09, 2014
Programming
110
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Ten Commandments of the Ruby Programmer
Emilio Gutter
October 09, 2014
More Decks by Emilio Gutter
See All by Emilio Gutter
¿No más secretos?
egutter
0
33
Collaborative entrepreneurship case study
egutter
0
35
Self-Organizing the organization
egutter
1
180
Los diez mandamientos del programador ágil
egutter
0
680
Growing apprentices
egutter
0
32
Other Decks in Programming
See All in Programming
Signal Forms: Beyond the Basics @ngBaguette 2026 in Paris
manfredsteyer
PRO
0
250
DynamoDBには集計系のクエリがないけどなんとかしたい
musan
1
140
タクシーアプリ『GO』の バックエンド開発のおける AI利活用と若者のすべて
pyama86
3
2k
メソッドのジェネリクスでGoの夢は広がるか? / Kyoto.go #65
utgwkk
3
780
LLM本来の能力を解き放つサンドボックス技術とAI民主化への適用
yukukotani
3
4.1k
Oxlintのカスタムルールの現況
syumai
6
1.1k
CSC307 Lecture 17
javiergs
PRO
0
320
「エンジニアインターン、どうやって取った?」準備のリアルを語るLT会 Progate BAR
akiomatic
0
130
IBM Bobを活用したレガシーアプリの最新化
oniak3ibm
PRO
1
200
Even G2とAWSで推しのエージェントを召喚しよう!
har1101
1
120
Strategic Design in the Frontend: Moduliths & Micro Frontends @DDDEurope
manfredsteyer
PRO
0
100
Snowflake Summitでの新機能 CoCo / CoWork / snowflake-summit-2026-overall-what-new-coco
tatsuhiro
1
140
Featured
See All Featured
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.3k
Scaling GitHub
holman
464
140k
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.2k
Fashionably flexible responsive web design (full day workshop)
malarkey
408
66k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
From π to Pie charts
rasagy
0
210
Building an army of robots
kneath
306
46k
The Curious Case for Waylosing
cassininazir
1
390
[SF Ruby Conf 2025] Rails X
palkan
2
1.1k
Fireside Chat
paigeccino
42
4k
Testing 201, or: Great Expectations
jmmastey
46
8.2k
Raft: Consensus for Rubyists
vanstee
141
7.5k
Transcript
THE TEN COMMANDMENTS of the ruby programmer
I AM EMILIO A RUBY PROGRAMMER Software developer +15 yrs
10Pines founder Agiles community founding member agiles 2012 conference co-chair husband, father and homeBrewer
I. Thou shalt have no domain objects coupled with thy
frameworks
class Speaker < ActiveRecord::Base ! devise :omniauthable, :omniauth_providers => [:facebook]
! def approve_session(session) # do something SessionMailer.approve(speaker: self, session: session).deliver end ! end
II. THOU SHALT NOT STEAL & PASTE CODE
public List selectPending(List registrations) { ! List pending = new
ArrayList(); for (Registration registration: registrations) { if (!registration.isPaid()) { pending.add(registration); } } return pending; }
! def select_pending(registrations) registrations.reject(&:paid?) end ! !
class SessionsController < ApplicationController ! def create ! @session =
Session.new(session_params) ! if @session.save redirect_to my_sessions_path, notice: 'Session created successfully' else render :new end ! end end
class Program ! def find_by_author(author) ! sessions = Session.where(author: author,
approved: true) ! if sessions.empty? # do something else # do something end end ! end
III. THOU SHALT NOT USE NIL
class AttendeePresenter ! def phone_number ! unless self.address.nil? unless self.address.phone_number.nil?
self.address.phone_number else 'Phone number not present' end else 'Address not present' end end ! end
class Attendee def initialize(address) if address.nil? raise ArgumentError, 'Address is
required' end @address = address end ! def address @address || UnknownAddress.new end ! def phone_number Optional.new(@address). within {|address| address.phone_number} end end
IV. THOU SHALT NOT USE IF
class BankAccount ! def process a_transaction ! if a_transaction.type ==
:purchase # charge transaction fee else # assume refund end end ! end
class BankAccount ! def process a_transaction a_transaction.process self end !
def process_purchase a_transaction # charge transaction fee end ! def process_refund a_transaction # refund transaction fee end ! end
class Purchase < Transaction ! def process a_payment_method a_payment_method.process_purchase self
end end ! class Refund < Transaction ! def process a_payment_method a_payment_method.process_refund self end end
V. THOU SHALT NOT MOCK
require 'spec_helper' ! describe Registration do ! it 'pays a
registration' do ! attendee_id = 1 a_registration = double("Registration") an_attendee = double("Attendee", registration: a_registration) ! allow(Attendee).to receive(:find) { an_attendee } ! expect(a_registration).to receive(:paid=).with(true) expect(a_registration).to receive(:save).and_return(true) ! expect_any_instance_of(PaypalAccount).to receive(:process) ! Registration.pay(attendee_id) ! end end
VI. THOU SHALT NOT TAKE THY TESTS IN VAIN
VI. THOU SHALT NOT TAKE THY IN VAIN VII. REMEMBER
TO REFACTOR EVERY DAY
VI. THOU SHALT NOT TAKE THY IN VAIN VII. REMEMBER
TO REFACTOR VII. THOU SHALT BEAR YOUR FELLOW PROGRAMMERS AND PAIR WITH THEM
IX. CHALLENGE HONOUR /[RUBY|RAILS|.*]/ FATHER AND MOTHER
X. NO GRAVEN PRACTICES
QUESTIONS? comments, critics, compliments
THANKS!!! email:
[email protected]
twitter: @10pines site: dev.10pines.com blog: blog.10pines.com