$30 off During Our Annual Pro Sale. View Details »
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
OOP, Double Dispatch and Visitor Pattern
Search
Akihito Koriyama
May 24, 2024
Technology
2
100
OOP, Double Dispatch and Visitor Pattern
OOPのエッセンスとビジターパターンを使ったディスパッチのデザインパターン。弁護士ドットコム社で紹介。
Akihito Koriyama
May 24, 2024
Tweet
Share
More Decks by Akihito Koriyama
See All by Akihito Koriyama
app-state-diagram
koriym
0
22
BEAR.Sunday 2014-2024
koriym
0
52
イベント駆動コンテンツ (a.k.a Webアプリケーションの効率を再定義するBEAR.Sundayの分散キャッシングフレームワーク)
koriym
4
7k
Unconf: RWA読書会
koriym
0
510
REST 6+4の制約
koriym
2
2.7k
RESTful Web API 読書会 #1
koriym
3
280
RESTの力 / The Power of REST
koriym
10
7.4k
全てを結ぶ力 (2019)
koriym
3
850
REST 6+4=9の制約
koriym
3
1k
Other Decks in Technology
See All in Technology
品質管理チームのEMとして大事にしていること / QA EM
nihonbuson
0
840
お悩みハンドブック紹介資料
grafferhandbook
0
1.4k
Kaggleふりかえり会〜LLM 20 Questions & ISIC 2024
recruitengineers
PRO
2
190
Oracle Base Database Service 技術詳細
oracle4engineer
PRO
5
52k
検証と資産化を形にするプロダクト組織へ/tapple_pmconf2024
corin8823
1
9.5k
Oracle Base Database Service:サービス概要のご紹介
oracle4engineer
PRO
0
15k
Kubeshark で Kubernetes の Traffic を眺めてみよう/Let's Look at k8s Traffic with Kubeshark
kota2and3kan
0
140
My Generation 年配者がこの先生きのこるには (Developers CAREER Boost 2024 Edition)/My Generation How elder engineers can survive
kwappa
3
370
アジャイルテストの4象限で考える プロダクト開発の品質への向き合い方
nagano
1
900
Kubernetesトラフィックルーティング徹底解説/Kubernetes-traffic-deep-dive
oracle4engineer
PRO
3
350
つくってあそぼ! ユビキタス言語作文の紹介
ndadayo
1
150
多様なロール経験が導いたエンジニアキャリアのナビゲーション
coconala_engineer
1
160
Featured
See All Featured
How to Think Like a Performance Engineer
csswizardry
21
1.2k
Put a Button on it: Removing Barriers to Going Fast.
kastner
59
3.6k
Done Done
chrislema
181
16k
RailsConf 2023
tenderlove
29
920
GitHub's CSS Performance
jonrohan
1030
460k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
59k
Being A Developer After 40
akosma
87
590k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
330
21k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
Transcript
001 %PVCMF%JTQBUDIBOE 7JTJUPS1BUUFSO "LJIJUP,PSJZBNB
1BSU001ͱखଓܕ 001BOEQSPDFEVSBMUZQFT
-PHJD %BUB
࢛֯ܗͷ໘ੵΛٻΊΔ 'JOEJOHUIFBSFBPGBRVBESBOHMF
-PHJD %BUB < > BYC
-PHJD%BUBΛΔඞཁ͕͋Δ -PHJDOFFETUPLOPX%BUB
"SFB %BUB BYC QVCMJDB QVCMJDC
ΧϓηϧԽͰ͖ͯͳ͍ /PUFODBQTVMBUFE
-PHJD %BUB BYC HFU" JOU HFU# JOU
ΧϓηϧԽͰ͖ͯͳ͍ /PUFODBQTVMBUFE
w 8IZHFUUFSBOETFUUFSNFUIPETBSFFWJM w (FUUFS4FUUFSѱͩɻҎ্ɻ
ΦϒδΣΫτࢦ PCKFDUPSJFOUFE
4IBQF < > BYC
4IBQF < > BYC BSFB JOU
खଓ͖ܕ QSPDFEVSBMUZQF
$MJFOU %BUB BYC B C
5FMM
4IBQF < > BYC BSFB JOU
"TL
$MJFOU %BUB BYC B C
5FMM %POUBTL
5FMMࣗݾنత 5FMMJTTFMGEJTDJQMJOFE
ΧϓηϧԽ FODBQTVMBUJPO
ΦϒδΣΫτࢦ PCKFDUPSJFOUFE
"TL ϩδοΫ͕σʔλͷ֎ʹ͋Δ *O"TL UIFMPH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ͷઃܭ %*DPNQJMFSEFTJHO
Πϯελϯεੜ JOTUBODFDSFBUJPO
%BUB wOFX*OTUBODF wDMBTT/BNF wBSHVNFOUT wBSHVNFOU wTFUUFS.FUIPET wTFUUFS.FUIPE wNFUIPE/BNF wBSHVNFOUT
wBSHVNFOU Dependency
ґଘʹґଘ͕͋Δ %FQFOEFODFVQPOEFQFOEFODF
%BUB wOFX*OTUBODF wDMBTT/BNF wBSHVNFOUT wBSHVNFOU wTFUUFS.FUIPET wTFUUFS.FUIPE wNFUIPE/BNF wBSHVNFOUT
wBSHVNFOU Dependency
7JTJUPSίϯύΠϥͷઃܭ 7JTJUPSDPNQJMFSEFTJHO
ड͚औͬͨΦϒδΣΫτར༻Λ܁Γฦ͢ 3FQFBUSFDFJWFEPCKFDUVTF
w WJTJU%FQFEFODZ w WJTJU/FX*OTOUBDF w WJTJU"SHVNFOUT w WJTJU"SHVNFOU w
WJTJU4FUUFS.FUIPET w WJTJU4FUUFS.FUIPE %BUB w OFX*OTUBODF wDMBTT/BNF wBSHVNFOUT wBSHVNFOU wTFUUFS.FUIPET wTFUUFS.FUIPE wNFUIPE/BNF wBSHVNFOUT wBSHVNFOU Visitor Dependency
4FUUFS.FUIPETͷ߹ 'PS4FUUFS.FUIPET
%BUB SetterMethods public function accept(VisitorInterface $visitor) { $visitor->visitSetterMethods($this->setterMethods); }
w Visitor public function visitSetterMethods( array $setterMethods ) { foreach
($setterMethods as $setterMethod) { $setterMethod->accept($this); } }
7JTJUPSड͚औͬͨΦϒδΣΫτΛ ʑͱεΫϦϓτʹ 5IF7JTJUPSTFOETUIFSFDFJWFEPCKFDUUPUIFTDSJQUDPEF
ෳࡶͳߏͷBDDFQUͱWJTJUΛ܁Γฦ͠ ݁ہ࠷ॳͷίʔϧ͕࠷ऴ݁ՌΛड͚औΔ 3FQFBUFEBDDFQUBOEWJTJUPGDPNQMFYTUSVDUVSFT &WFOUVBMMZUIF fi STUDBMMSFDFJWFTUIF fi OBMSFTVMU
w WJTJU%FQFEFODZ w %BUB w Visitor Dependency
ͦΕͧΕͷϝιου ہॴతͳࣝͱλεΫ͔͠ཁٻ͞Εͳ͍ 0OMZMPDBMLOPXMFEHFBOEUBTLTBSFSFRVJSFE
ෳࡶͳґଘߏΛίϯύΠϥΒͳ͍ $PNQJMFSTBSFVOBXBSFPGDPNQMFYEFQFOEFODZTUSVDUVSFT
ࠓԿΛ͢Δ͔ͱɺ࣍ʹԿΛݺͿ͔ ଞʹؔ৺͕ͳ͍ 8IBUUPEPOPXBOEXIBUUPDBMMOFYU /PUJOUFSFTUFEJOBOZUIJOHFMTF
શମΛΔίϯμΫλʔ͍ͳ͍ /PDPOEVDUPSLOPXTUIFXIPMFTUSVDUVSF
ΦʔέετϨʔγϣϯͰͳ͘ɺίϨΦάϥϑΟʔ $IPSFPHSBQIZ OPUPSDIFTUSBUJPO
σʔλͱϩδοΫΛ͠ɺΦϒδΣΫ τߏͷৄࡉΛΒͣʹ৽͍͠ϩδοΫ Λద༻Ͱ͖ΔσβΠϯύλʔϯ %FTJHOQBUUFSOTUIBUTFQBSBUFEBUBGSPNMPHJDBOE BMMPXOFXMPHJDUPCFBQQMJFEXJUIPVULOPXJOHUIF EFUBJMTPGUIFPCKFDUTUSVDUVSF