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
関数型でGoFのデザインパターンやってみる
Search
ponday
September 06, 2019
Programming
1.7k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
関数型でGoFのデザインパターンやってみる
こわくない関数型プログラミング勉強会@福岡 #2(2019/09/06)の発表資料です。
ponday
September 06, 2019
More Decks by ponday
See All by ponday
TypeScriptの型表現
honda
10
3.2k
Web Componentsの今
honda
1
480
これまでのReact、これからのReact
honda
0
350
Gatsbyお試し
honda
0
150
styled-components or emotion?
honda
0
730
Web ComponentsとAngular
honda
0
170
Atomic Design周りについての私見
honda
1
820
え、まだWeb Componentsを未来の技術だと思ってるの?
honda
2
890
Web Componentsの動向とPolymer
honda
4
2.8k
Other Decks in Programming
See All in Programming
HTML-in-Canvasで作る未来のWeb UI表現
clockmaker
5
6k
AmebaブログはKMPから卒業します
kmars0605
0
310
AI時代のTerminal環境を UNIX哲学で設計・運用する
yasunori0418
1
310
AI-Powered Domain-Driven Design
ziobrando
0
360
そのデザイントークン、Flutterでも同じ見た目になりますか?
nakamizu
0
130
Materialが消えた日 〜真っ白なFlutterキャンバスにRenderObjectで絵を描く〜
umigishiaoi
0
120
Spec-driven Development with AI
simas
PRO
0
2.2k
複雑なUIコンポーネントとの ⻑い付き合い⽅:波及するバグからテスト戦略を経て、安全な再設計へ
mixplace
0
490
AI主導のプログラミング学習アプリを作ってみた
econanringo
0
200
気持ちぃ〜角丸 Squircle
ryu1013
0
370
Apple Intelligenceとオンデバイス時代の到来
yahir0
0
170
Next.js: The final boss of Web Performance
guaca
0
360
Featured
See All Featured
Fashionably flexible responsive web design (full day workshop)
malarkey
409
67k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
3.1k
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
500
Building Flexible Design Systems
yeseniaperezcruz
330
41k
WCS-LA-2024
lcolladotor
0
940
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
460
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6.2k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
1k
It's Worth the Effort
3n
188
29k
GraphQLとの向き合い方2022年版
quramy
50
15k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
50
10k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.9k
Transcript
関数型でデザインパターンやってみる こわくない関数型プログラミング勉強会@福岡 #2 / Sep 5th, 2019 ponday (@ponday_dev)
Profile - ponday (Honda, Yusuke) - フロントエンド好き - 副業もやってます
前回のイベントにて
GoFのデザインパターンを関数型で書いたら どうなりますか?
やってみる
GoFのデザインパターン - Abstract Factory - Adapter - Bridge - Builder
- Chain of Responsibility - Command - Composite - Decorator - Facade - Factory Method - Flyweight - Interceptor - Iterator - Mediator - Memento - Observer - Prototype - Proxy - Singleton - State - Strategy - Template Method - Visitor
State / Strategy - 持つべき振る舞いをinterfaceに定義 - interfaceを実装して実際の振る舞いを作成 - インスタンスを差し替えて動作を切り替え
例:Stateパターン
例:Stateパターン
Builder - インスタンスの操作を担うBuilderをinterfaceとして定義 - Builderを実装して具体的な方法を定義 - DirectorはBuilderを使ったインスタンスの構築方法を定義
例:Builderパターン
例:Builderパターン
似たような処理は書けるけど......
そもそもGoFのデザパタは OOP向け (不要なものも...)
関数型プログラミングでは、 高階関数 と 部分適用 を多用する
高階関数 - 関数を引数、戻り値で使う関数のこと - map / filter / reduce など
- 処理の移譲などに使う
部分適用 - 関数の引数の一部をあらかじめ固定する処理
例:高階関数と部分適用
例:高階関数と部分適用 高階関数
例:高階関数と部分適用 部分適用
例:高階関数と部分適用
例:高階関数と部分適用(パターン2)
例:高階関数と部分適用(パターン2)
まとめ - GoFはOOPについてのデザインパターン - 関数型プログラミングでも有効というわけではない - 実現できない or 余計なものもある
- 関数型プログラミングでは高階関数と部分適用を多用する - 処理の分岐や移譲は高階関数で実現
さいごにちょっと 宣伝
9/22の技術書典7で関数型プログラミングの本出します ↓他新刊(自社有志による執筆)
https://frontend-conf.fukuoka.jp/