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
独立したコアレイヤパターンの適用 - fortee 編 - / fortee-meets-in...
Search
shin1x1
November 30, 2019
Programming
4.1k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
独立したコアレイヤパターンの適用 - fortee 編 - / fortee-meets-independent-core-layer-pattern
2019/11/30 大改修!PHPレガシーコードビフォーアフター
https://phperkaigi.connpass.com/event/155509/
shin1x1
November 30, 2019
More Decks by shin1x1
See All by shin1x1
Xdebug と IDE による デバッグ実行の仕組みを見る / Exploring-How-Debugging-Works-with-Xdebug-and-an-IDE
shin1x1
0
660
抽象化という思考のツール - 開発現場での活用 - / Abstraction-as-a-Tool-for-Thinking-in-dev
shin1x1
0
160
抽象化という思考のツール - 理解と活用 - / Abstraction-as-a-Tool-for-Thinking
shin1x1
1
1.5k
php-fpm がリクエスト処理する仕組みを追う / Tracing-How-php-fpm-Handles-Requests
shin1x1
6
4.1k
PHP ユーザのための OpenTelemetry 入門 / phpcon2024-opentelemetry
shin1x1
3
2.5k
PHPコードの実行モデルを理解する / Understanding-the-PHP-Execution-Model
shin1x1
2
3.4k
制約の力 - 状態を限定する -
shin1x1
6
5.8k
Apple Silicon Mac 時代の PHP 開発環境構築 2021 / php-dev-env-on-m1-mac-era
shin1x1
2
4.9k
Docker イメージのマルチアーキテクチャビルド / docker-muti-arch-build
shin1x1
1
580
Other Decks in Programming
See All in Programming
AIに既存システムを理解させる技術 ~レガシーを見捨てないハーネスエンジニアリング入門~
ochtum
0
200
Discordを用いたラボオートメーション関連情報収集の自動化
noguhiro2002
0
490
FDEとは、何者なのか?
masapyon1212
0
130
異なる設計思想のフレームワークを経験して得た学び
amekuhideki
2
1.5k
一参加者から『中の人』へ 〜全通PHPerがブースに立って学んだ、カンファレンスを100倍楽しむコツ〜
wp_daisuke
0
110
高専、大学編入、そして未踏へ〜プロダクト開発とキャリアの歩み - Technical College, University Transfer, and On to “Mitou” / My Journey in Product Development and Career
pkmiya
0
130
Webエンジニアなのにブラウザの仕組みがわからないので、Pythonで自作してみた
tatsuki12
4
1.7k
GraphRAGのKnowledge Graphを 直接!見る/View-GraphRAG's-KnowledgeGraph-directly!
tyumugi1113
0
180
Hello, Hiroshima Geospatial Data! — Exploring DoboX with Python
ra0kley
0
160
Claude Codeを組織的に動かして月400PRを実現した話
happy_ryo
0
250
My Marp Sample
sinoue0108
0
140
AIの中の人になってみる
htkym
0
150
Featured
See All Featured
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
680
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
550
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
11k
RailsConf 2023
tenderlove
30
1.5k
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
4.3k
Site-Speed That Sticks
csswizardry
13
1.5k
30 Presentation Tips
portentint
PRO
1
390
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
560
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.3k
Raft: Consensus for Rubyists
vanstee
141
7.7k
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
840
Fashionably flexible responsive web design (full day workshop)
malarkey
408
67k
Transcript
独立したコアレイヤパターンの適用 fortee 編 2019/11/30 PHP レガシーコードビフォーアフター @shin1x1
@shin1x1 新原(しんばら) 雅司 1× 1株式会社 Web アプリケーション 開発 技術サポート PHP
の現場 (Podcast) https://php-genba.shin1x1.com/ 2
Agenda 独立したコアレイヤパターン fortee への適用例 まとめ 3
独立したコアレイヤパターン 4
独立したコアレイヤパターン アーキテクチャパターンの一つ システムを 2 つのレイヤに分離 コアレイヤ アプリケーションレイヤ 5
コアレイヤ コアロジック(What )を実装 IO 等の技術詳細は実装しない コアレイヤのみに依存するようにする フレームワークには依存しないのが理想 ただ局所的に依存する場合もある ユースケース、ドメインモデルなど 6
インターフェイス コアレイヤが利用する技術詳細を インターフェイスで定義 DB アクセス Mail 送信 API 呼び出し コアレイヤのコードはインターフェイスを介して
IO 等の技術詳細を実装 7
アプリケーションレイヤ 技術詳細(How )の実装 コアレイヤで定義したインターフェイスを実装 フレームワーク、ライブラリを活用 UI からコアレイヤの実行(HTTP, CLI など) 8
9
10
11
ポートとアダプタ 12
ポートとアダプタ コアレイヤ: インターフェイス = ポート アプリケーションレイヤ: 実装 = アダプタ 13
ポートとアダプタ アダプタを変えてもコアレイヤには影響しない 14
Ports & Adapters http://www.dossier- andreas.net/software_architecture/ports_and_adapters.html 15
独立したコアレイヤパターン コアレイヤとアプリケーションレイヤに分離 コアレイヤ: コアロジック アプリケーションレイヤ: UI 、技術詳細 コアレイヤ内での IO 処理
コアレイヤにインターフェイス定義(ポート) アプリケーションレイヤで実装(アダプタ) 16
fortee への適用 17
fortee @tomzoh さんが、2017/12 から開発 CakePHP 3 で実装 PHP 7.2 (今回デモ用に
7.4 ) Web ページと API がエンドポイントによって混在 18
パターン適用対象 プロポーザルに Fav を付ける、外す API POST /sample-conference/proposal/fav uuid = プロポーザルを示す
UUID on = true なら Fav を付ける。それ以外なら外 す。 19
適用手順 [core] コントローラのコードをユースケースに移行 HTTP Request 等で必要な値は引数で渡す HTTP Reponse 等で必要な値は戻り値で返す IO
関連の処理はインターフェイス(ポート)化 [core] ユースケースのテスト [app] アダプタ実装 [app] コントローラからユースケースを実行 20
demo 21
コードを役割でグループ分け コントローラメソッドに全てのコードがある 役割によってグループ分け HTTP Request / Response IO (RDBMS) Business
Logic 22
レイヤに分ける HTTP Request / Response ---> アプリケーションレイヤ(Controller ) IO (RDBMS)
---> コアレイヤ(ポート) ---> アプリケーションレイヤ(アダプタ) Business Logic ---> コアレイヤ(ユースケース) 23
既存実装への適用アイデア 漸進的に進める ロジックは同じでパターン適用 テスト後にロジックをリファクタリング コアレイヤが完成したらコントローラから実行 適用する箇所を絞る 単純な読み込みだけなら適用しない ビュー用の読み込みはコントローラに残す 24
まとめ コアレイヤは、どこから呼ばれても良い Web, CLI, test コアレイヤは、IO の実装を知らなくて良い コアレイヤの適用箇所を少しづつ増やす 0 or
100 ではなく、除々に 25
Q? @shin1x1 26