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
独立したコアレイヤパターンの適用 - fortee 編 - / fortee-meets-in...
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
shin1x1
November 30, 2019
Programming
4.2k
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
700
抽象化という思考のツール - 開発現場での活用 - / Abstraction-as-a-Tool-for-Thinking-in-dev
shin1x1
0
170
抽象化という思考のツール - 理解と活用 - / Abstraction-as-a-Tool-for-Thinking
shin1x1
1
1.5k
php-fpm がリクエスト処理する仕組みを追う / Tracing-How-php-fpm-Handles-Requests
shin1x1
6
4.2k
PHP ユーザのための OpenTelemetry 入門 / phpcon2024-opentelemetry
shin1x1
3
2.5k
PHPコードの実行モデルを理解する / Understanding-the-PHP-Execution-Model
shin1x1
2
3.4k
制約の力 - 状態を限定する -
shin1x1
6
5.9k
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
C#の現在地 進化の歴史と、AI時代の.NET Everywhere
neuecc
5
4.5k
JRuby: Past, Present, and Future
headius
0
210
そのリトライ、死んだコネクションを使い回していませんか ── GoのHTTPクライアントとHTTP/2を実プロダクト障害から学び直す
myus4a
0
340
技術的負債を組織課題として解く-増えすぎたマイクロサービスとの戦い-
reimaru
1
2.6k
The Rails Doctrine Decade
koic
2
430
Are APIs Still Relevant in the AI Era?
soyuka
0
380
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
1
400
Webの地図
yosuke_furukawa
PRO
6
5k
マイコン向けの軽量Ruby「PicoRuby」で各種デバイスを制御するネイティブアプリの実現手法
bash0c7
0
460
モジュールの視点からSwiftを読み解く #iosdc
s_shimotori
0
280
[ハンズオン]AIへの指示だけで「五目並べ」を作ってみよう
satoshi256kbyte
1
310
IBM Bob Dojo #1 仕様駆動開発入門
oniak3ibm
PRO
0
320
Featured
See All Featured
So, you think you're a good person
axbom
PRO
2
2.2k
SEO for Brand Visibility & Recognition
aleyda
0
4.8k
My Coaching Mixtape
mlcsv
0
330
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
20k
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
250
Test your architecture with Archunit
thirion
2
2.4k
A Soul's Torment
seathinner
8
3.7k
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
600
Rails Girls Zürich Keynote
gr2m
96
14k
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
Between Models and Reality
mayunak
4
480
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
480
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