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
Always default to false - Paul Grayson
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Las Vegas Ruby Group
January 29, 2014
81
0
Share
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
170
Windows Automation - Howard Feldman
lvrug
0
110
Separating Your Application from Rails - Brian Hughes
lvrug
0
160
SWIG and Ruby - David Grayson
lvrug
0
100
Practical Object-Oriented Design in Ruby - Charles Jackson
lvrug
3
150
The Hamster Gem - Ryan Mulligan
lvrug
1
120
Varnish+Redis - Russ Smith
lvrug
1
140
Lambdas and Pops - Jan Hettich
lvrug
0
110
Making Good Use of Fonts - Russ Smith
lvrug
1
110
Featured
See All Featured
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
1
250
The Curse of the Amulet
leimatthew05
1
13k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
300
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
560
Optimising Largest Contentful Paint
csswizardry
37
3.7k
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.3k
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
720
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
220
WENDY [Excerpt]
tessaabrams
11
38k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
230
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
210
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