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
Emilio Gutter
October 09, 2014
Programming
120
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
34
Collaborative entrepreneurship case study
egutter
0
38
Self-Organizing the organization
egutter
1
190
Los diez mandamientos del programador ágil
egutter
0
680
Growing apprentices
egutter
0
35
Other Decks in Programming
See All in Programming
Flow は今どうなっているか
mizdra
PRO
0
690
AI Readyの正体はデータマネジメントだ メダリオン2.0の最前線
freee
PRO
0
360
tsc.rip を支える技術 / Kyoto.なんか #8
susisu
0
160
Claude CodeとAgentCore Gatewayを繋ぐ際の認証認可 / Authentication and authorization when connecting Claude Code with AgentCore Gateway
har1101
2
370
【デモ】Kiroで体験する仕様駆動開発|設計からコーディングまでAIと進める開発フロー
cmkudo
0
360
FastAPI の並行処理モデルを完全に理解する
hoto17296
8
2.9k
運用ダッシュボードの設計を誰も教えてくれないのだけどみなさんどうしてるんですか? - チームに監視するという文化を根付かせるための第一歩を踏みたい -
satoshi256kbyte
1
140
コンパウンドプロダクト開発のためのローカルプロセスマネージャー再発明 #layerxgo
izumin5210
0
210
レビュー履歴をAIに食わせて、 Compose移行を加速するs
shihochan
0
200
そこに3びきプロダクトがいるじゃろう——生成AI時代における“価値が届かない理由”の構造
kosuket
0
570
PostgreSQL 18で考えるUUID主キー
kazuhiro1982
0
500
【QA Test Talk Vol.8】AI-DLC による Whole Team Approach の加速
pkshadeck
PRO
0
230
Featured
See All Featured
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.4k
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
400
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.8k
Odyssey Design
rkendrick25
PRO
2
770
What's in a price? How to price your products and services
michaelherold
247
13k
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
250
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
500
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.2k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
290
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
4.2k
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
660
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.8k
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