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
関数型でGoFのデザインパターンやってみる
Search
ponday
September 06, 2019
Programming
1
1.5k
関数型でGoFのデザインパターンやってみる
こわくない関数型プログラミング勉強会@福岡 #2(2019/09/06)の発表資料です。
ponday
September 06, 2019
Tweet
Share
More Decks by ponday
See All by ponday
TypeScriptの型表現
honda
10
3.1k
Web Componentsの今
honda
1
450
これまでのReact、これからのReact
honda
0
320
Gatsbyお試し
honda
0
120
styled-components or emotion?
honda
0
700
Web ComponentsとAngular
honda
0
140
Atomic Design周りについての私見
honda
1
750
え、まだWeb Componentsを未来の技術だと思ってるの?
honda
2
860
Web Componentsの動向とPolymer
honda
4
2.6k
Other Decks in Programming
See All in Programming
ゲームの物理 剛体編
fadis
0
390
チームをチームにするEM
hitode909
0
420
re:Invent 2025 のイケてるサービスを紹介する
maroon1st
0
160
0→1 フロントエンド開発 Tips🚀 #レバテックMeetup
bengo4com
0
440
tparseでgo testの出力を見やすくする
utgwkk
2
330
フルサイクルエンジニアリングをAI Agentで全自動化したい 〜構想と現在地〜
kamina_zzz
0
330
メルカリのリーダビリティチームが取り組む、AI時代のスケーラブルな品質文化
cloverrose
2
430
[AI Engineering Summit Tokyo 2025] LLMは計画業務のゲームチェンジャーか? 最適化業務における活⽤の可能性と限界
terryu16
1
140
クラウドに依存しないS3を使った開発術
simesaba80
0
200
AI Agent Dojo #4: watsonx Orchestrate ADK体験
oniak3ibm
PRO
0
120
Navigating Dependency Injection with Metro
l2hyunwoo
1
200
PC-6001でPSG曲を鳴らすまでを全部NetBSD上の Makefile に押し込んでみた / osc2025hiroshima
tsutsui
0
200
Featured
See All Featured
Leading Effective Engineering Teams in the AI Era
addyosmani
9
1.4k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
10
770
Practical Orchestrator
shlominoach
190
11k
A Modern Web Designer's Workflow
chriscoyier
698
190k
Designing for humans not robots
tammielis
254
26k
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
74
Crafting Experiences
bethany
0
24
Color Theory Basics | Prateek | Gurzu
gurzu
0
160
Learning to Love Humans: Emotional Interface Design
aarron
274
41k
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
0
210
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
36
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/