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
Life Without Footguns (Part 2)
Search
Chew Choon Keat
March 26, 2021
Programming
0
160
Life Without Footguns (Part 2)
Chew Choon Keat
March 26, 2021
Tweet
Share
More Decks by Chew Choon Keat
See All by Chew Choon Keat
Life Without Footguns (Part 1)
choonkeat
0
150
A Programmer’s Red Pill: Pure, Functional, and Typed
choonkeat
0
190
GraphQL for web devs who don't need it
choonkeat
1
210
TDD for people who don't need it
choonkeat
1
74
File Upload 2015
choonkeat
0
120
Other Decks in Programming
See All in Programming
CSS Linter による Baseline サポートの仕組み
ryo_manba
1
160
JAWS Days 2025のインフラ
komakichi
1
370
バッチを作らなきゃとなったときに考えること
irof
2
560
Djangoにおける複数ユーザー種別認証の設計アプローチ@DjangoCongress JP 2025
delhi09
PRO
4
520
推しメソッドsource_locationのしくみを探る - はじめてRubyのコードを読んでみた
nobu09
2
370
The Price of Micro Frontends… and Your Alternatives @bastacon 2025 in Frankfurt
manfredsteyer
PRO
0
280
Better Code Design in PHP
afilina
0
190
Generating OpenAPI schema from serializers throughout the Rails stack - Kyobashi.rb #5
envek
1
440
Datadog DBMでなにができる? JDDUG Meetup#7
nealle
0
160
Drawing Heighway’s Dragon- Recursive Function Rewrite- From Imperative Style in Pascal 64 To Functional Style in Scala 3
philipschwarz
PRO
0
180
AIプログラミング雑キャッチアップ
yuheinakasaka
21
5.4k
Swift Testingのモチベを上げたい
stoticdev
2
220
Featured
See All Featured
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
21
2.5k
Faster Mobile Websites
deanohume
306
31k
Making Projects Easy
brettharned
116
6.1k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
11
550
A better future with KSS
kneath
238
17k
Why Our Code Smells
bkeepers
PRO
336
57k
Imperfection Machines: The Place of Print at Facebook
scottboms
267
13k
Done Done
chrislema
182
16k
How STYLIGHT went responsive
nonsquared
99
5.4k
The Power of CSS Pseudo Elements
geoffreycrofte
75
5.5k
VelocityConf: Rendering Performance Case Studies
addyosmani
328
24k
It's Worth the Effort
3n
184
28k
Transcript
Life Without Footguns @choonkeat March 2021
About • Basic • C, Perl, Java • Javascript &
Ruby on Rails for 10 years • Go and Elm in the past few years • @choonkeat
About • Basic • C, Perl, Java • Javascript &
Ruby on Rails for 10 years • Go and Elm in the past few years • @choonkeat How to do things How to NOT do things
Anyone happy with this? nope
Why is it common to see this? well…
It was clean when I started
Since data is all here, add a Method
A magnet to add more Method
Does every Method use all the data? nope
“You wanted a banana but what you got was a
gorilla holding the banana and the entire jungle.” — Joe Armstrong (Erlang) Funny quip
“You wanted to call the formatUserName method but you’d have
to wait for Zookeeper to boot and Kafka to connect” — Me Has costs
:. Method = Footgun banana-gorilla-jungle code is less maintainable and
less reusable
Write plain functions instead
A Function With Exact Arguments just the banana without gorilla
or jungle
A Good Thing ™ a function with exact arguments is
a maintainable and reusable unit of code
No Method = No Interface? But Interface is a Good
Thing ™, right?
❤ Interface is a Good Thing ™
Any Writer can “Write” 😘
Different Dependency Same “Write” 🥰
Can “interface” be a function?
But Different Dependency… 😖
Digression
Nobody: Functional programming articles: instead of add(3, 5) when
you curry, you can get add3(5) !!!11!!1 Digression
What’s “currying” actually good for
What’s “currying” actually good for
None
Call without that last argument…
Currying 🥘
Different Dependency Same “Write” sounds familiar?
Different Dependency Same “Write” sounds familiar?
Currying = Interface with Functions no wonder these functions are
always so simple. no ceremony to use
Implementing an “interface” is… hint: not method
sounds familiar? A Function With Exact Arguments
sounds familiar? A Function With Exact Arguments
A Good Thing ™ a function with exact arguments is
a maintainable and reusable unit of code