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
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
21
BEAR.Sunday 2014-2024
koriym
0
52
イベント駆動コンテンツ (a.k.a Webアプリケーションの効率を再定義するBEAR.Sundayの分散キャッシングフレームワーク)
koriym
4
6.9k
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
840
REST 6+4=9の制約
koriym
3
1k
Other Decks in Technology
See All in Technology
信頼性に挑む中で拡張できる・得られる1人のスキルセットとは?
ken5scal
2
530
OCI 運用監視サービス 概要
oracle4engineer
PRO
0
4.8k
AWS Lambdaと歩んだ“サーバーレス”と今後 #lambda_10years
yoshidashingo
1
170
複雑なState管理からの脱却
sansantech
PRO
1
140
Exadata Database Service on Dedicated Infrastructure(ExaDB-D) UI スクリーン・キャプチャ集
oracle4engineer
PRO
2
3.2k
スクラムチームを立ち上げる〜チーム開発で得られたもの・得られなかったもの〜
ohnoeight
2
350
ExaDB-D dbaascli で出来ること
oracle4engineer
PRO
0
3.8k
The Rise of LLMOps
asei
7
1.4k
OCI Security サービス 概要
oracle4engineer
PRO
0
6.5k
初心者向けAWS Securityの勉強会mini Security-JAWSを9ヶ月ぐらい実施してきての近況
cmusudakeisuke
0
120
インフラとバックエンドとフロントエンドをくまなく調べて遅いアプリを早くした件
tubone24
1
430
Terraform CI/CD パイプラインにおける AWS CodeCommit の代替手段
hiyanger
1
240
Featured
See All Featured
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
Making the Leap to Tech Lead
cromwellryan
133
8.9k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.8k
Building Flexible Design Systems
yeseniaperezcruz
327
38k
Keith and Marios Guide to Fast Websites
keithpitt
409
22k
Docker and Python
trallard
40
3.1k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
6.9k
Imperfection Machines: The Place of Print at Facebook
scottboms
265
13k
Building Adaptive Systems
keathley
38
2.3k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
27
840
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.1k
Bash Introduction
62gerente
608
210k
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 UIFMPHJDJ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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