Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Always default to false - Paul Grayson
Search
Las Vegas Ruby Group
January 29, 2014
88
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Always default to false - Paul Grayson
Las Vegas Ruby Group
January 29, 2014
More Decks by Las Vegas Ruby Group
See All by Las Vegas Ruby Group
Ruby ISO Standard - David Grayson
lvrug
0
190
Windows Automation - Howard Feldman
lvrug
0
130
Separating Your Application from Rails - Brian Hughes
lvrug
0
180
SWIG and Ruby - David Grayson
lvrug
0
120
Practical Object-Oriented Design in Ruby - Charles Jackson
lvrug
3
160
The Hamster Gem - Ryan Mulligan
lvrug
1
150
Varnish+Redis - Russ Smith
lvrug
1
160
Lambdas and Pops - Jan Hettich
lvrug
0
130
Making Good Use of Fonts - Russ Smith
lvrug
1
130
Featured
See All Featured
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.2k
Balancing Empowerment & Direction
lara
6
1.4k
Embracing the Ebb and Flow
colly
88
5.2k
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
3
3.9k
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
970
4 Signs Your Business is Dying
shpigford
187
23k
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
290
RailsConf 2023
tenderlove
30
1.6k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
800
Why You Should Never Use an ORM
jnunemaker
PRO
61
10k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.5k
brightonSEO & MeasureFest 2025 - Winning Strategies for Black Friday CRO & PPC - Christian Goodrich
cargoodrich
3
890
Transcript
Always default to false Paul Grayson Las Vegas Ruby User
Group 2014-01-29
Be opinionated! • There is a right way • Consistency
aids memory true false 1 exception 0 default
The default is already false or null in many contexts
Ruby: @var, if x, methods, [], etc. -> nil SQL: NULL Javascript: undefined C#/Java: bool/boolean defaults false Originates in digital circuits? - default is OFF
Options should be opt in ☐ YES, please add me
to your mailing list ✓
Fields, variables, conditionals # DO THIS: if on_mailing_list send_email end
# NOT THIS: if !on_mailing_list withhold_email end How would you even write that method? Body does not run by default
Be careful with true default <% if !out_of_stock %> <div
id="order_form"> ... </div> <% end %> Must remember to not put anything essential in here.
Emphasize connections def f if x exceptional_stuff else default_stuff end
more_stuff end The normal path Condition and code to handle it
true default complicates connections def f if !x default_stuff else
exceptional_stuff end more_stuff end The normal path Condition and code to handle it
The “guard clause” pattern def f return y if x
normal_stuff ... end The normal path Condition and code to handle it
Summary • Default false for all fields • Test for
unusual conditions (when possible) • Beware of conditionals with true default true false 1 exception 0 default