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
120
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
130
A Programmer’s Red Pill: Pure, Functional, and Typed
choonkeat
0
160
GraphQL for web devs who don't need it
choonkeat
1
190
TDD for people who don't need it
choonkeat
1
63
File Upload 2015
choonkeat
0
92
Other Decks in Programming
See All in Programming
Micro Frontends for Java Microservices - Devnexus 2024
mraible
PRO
0
490
FigmaとPHPで作る1ミリたりとも表示崩れしない最強の帳票印刷ソリューション
ttskch
43
19k
Java 22 Overview
kishida
1
180
はてなにおける CSS Modules、及び CSS Modules に足りないもの / CSS Modules in Hatena, and CSS Modules missing parts
mizdra
7
920
大規模UIKitベースアプリへのTCAの段階的導入/gradual-adoption-of-tca-in-a-large-scale-uikit-based-app
takehilo
1
150
雑に思考を整理する技術と効能
konifar
59
29k
2 週間で Twitter Bot を作ってみた
contour_gara
0
360
Hanami and htmx
bkuhlmann
0
210
Goのエラースタックトレースの歴史と今後
sonatard
7
1.2k
OpenAPIを中心に考えるAPI開発入門 / Introduction to API Development with a Focus on OpenAPI
seike460
PRO
2
170
Apache Hive 4 on Treasure Data
ryukobayashi
0
220
TYPO3 v13 – The road to LTS: What's new and new APIs
luisasofie_xoxo
0
200
Featured
See All Featured
Design by the Numbers
sachag
274
18k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
40
4.4k
Facilitating Awesome Meetings
lara
42
5.6k
What's new in Ruby 2.0
geeforr
337
31k
How STYLIGHT went responsive
nonsquared
92
4.8k
From Idea to $5000 a Month in 5 Months
shpigford
377
45k
Building Flexible Design Systems
yeseniaperezcruz
319
37k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
20
1.9k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
30
6k
It's Worth the Effort
3n
180
27k
Thoughts on Productivity
jonyablonski
58
3.8k
Practical Orchestrator
shlominoach
182
9.7k
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