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
実践、Interface
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
おぎ
February 11, 2024
2.4k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
実践、Interface
PHPConference関西2024の発表資料です
おぎ
February 11, 2024
More Decks by おぎ
See All by おぎ
テストは書くより消すのが難しい/Deleting tests are harder than writing
togishima
0
250
「10分以内に機能を消せる状態」 の実現のためにやっていること
togishima
1
920
そのプロダクトは誰のもの?
togishima
1
68
インターフェース設計のコツとツボ
togishima
2
1.5k
100行で書けるPSR-11
togishima
0
1.1k
ITなんもわからん素人がアジャイルと出会うまで
togishima
1
150
とあるWebエンジニアの生成AI活用事例
togishima
0
180
設計、Interface
togishima
0
130
PHPerを続ける理由
togishima
0
140
Featured
See All Featured
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
460
Ruling the World: When Life Gets Gamed
codingconduct
0
330
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
410
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
450
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
540
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
520
エンジニアに許された特別な時間の終わり
watany
109
250k
First, design no harm
axbom
PRO
2
1.3k
Six Lessons from altMBA
skipperchong
29
4.5k
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
380
Git: the NoSQL Database
bkeepers
PRO
432
67k
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
300
Transcript
実践、Interface PHPカンファレンス関西2024
自己紹介
名前:おぎ PHPer歴:4年目(自称にわか) 住んでるところ:秘境グンマー 所属:Innovator Japan.inc 特技:スノーボード
過去の発表等
Innovator Japan Inc. 日本発のビジネスデザインカンパニー 「人の可能性を最大限に引き出し、ウェルビーイングな社会を実現する 」
宣伝終わり
実践、Interface PHPカンファレンス関西2024
今日の話 • Interfaceで何ができるの? • Interfaceの何が嬉しいの? • まとめ
Interfaceで何ができるの?
例:会員制のメディアサイト よくある機能 - ログインの有無による表示の切り替え - 会員ステータスに応じたコンテンツの出し分け よくある追加要件 - 会員ステータスの種類を追加したい サンプルコードの段階を追いながら考えてみましょう
①素朴な実装
テンプレート直書き!!
①素朴な実装の問題点 • Viewにロジックが漏れているので会員が増えるたびに無限に分岐 が入り組んでいく(つらい) • 微妙に変数名やHTMLが変わっているとgrep検索でも引っかからな いので修正漏れが発生する(つらい) • テンプレートからどんな見た目になるのかが全く想像できない (つらい)
②具象への依存
Bladeのコードが抽象化された!
Postモデル内は分岐
②具象への依存の問題点 • テストはできるようになった • 会員を追加するのにUserモデル以外にPostモデルも修正が必要 (ウッ!) • そして多分似たような感じで会員のステータスに依存している箇所をすべて直す羽 目になる (つらい)
一つの変更に対して波及する箇所が多すぎる!🥺
③抽象への依存
③抽象への依存
③抽象への依存のメリット 抽象に依存することで使う側のコードがシンプルに
抽象に依存したことで シンプルで拡張性の高いコードになった🎉
Interfaceの何が嬉しいのか?
抽象に依存したことで シンプルで拡張性の高いコードになった🎉
というのは 結果の一つであって本質ではない
https://amzn.asia/d/9WkYDgp OO(オブジェクト指向)とは「ポリモーフィズム を使用することでシステムにあるすべてのソー スコードの依存関係を絶対的に制御する能 力」である。 〜Robert C. Martin〜
None
直接の依存がなくなった! 矢印の向きが逆転した!
Interfaceの効能 1. 薄いレイヤーが実装同士の間に生まれ、依存の向きが変わった (依存関係逆転原則) 2. 抽象に依存するようになったことで、使う側のプログラムが安定した (安定依存の原則) 3. 多彩なインスタンスを注入して拡張できるようになった (多態性)
任意の方向へ依存を向けることで 何に依存して、何に依存しないかを 選ぶことができる
まとめ
Interfaceの話は「アーキテクチャ」の話 ( ≠ EASY)
Interfaceが不要なパターン • 極端に小さいシステム → 2週間〜1ヶ月で書き直しできるようなシステム • 複雑でないシステム → 処理の中身の意図まですぐに把握できるコードベース •
短命・使い捨てのシステム → MVP等の場合は作り込むコストのほうが嵩む
Interfaceがあった方が良いパターン • 複数開発者が必要になる規模のシステム → 複数開発者で認識や概念の齟齬が起きにくい • 概念が複雑になりがちなシステム → 「接合部」を作ることで影響範囲を閉じることができる •
長期間稼働する前提のシステム → 開発者が入れ替わった時も制約がガイドの役割を果たす
https://x.com/suthio_/status/1691972270208803260?s=20
つまり「チーム開発」の話
設計するアーキテクトだけでなく プログラマも理解する必要がある
おすすめの発表/書籍
https://fortee.jp/phpcon-kansai2024/proposal/b3f6ed97-8551-4 0da-90b1-3a14697df303
https://fortee.jp/phpcon-kansai2024/proposal/0d9231ed-2f64-4 908-bd16-863922f56c0f
https://fortee.jp/oocon-2024/proposal/857fd0a4-b04e-41f1-a0f3-6bbeb3fa0779
https://amzn.asia/d/dj7nHWu https://amzn.asia/d/c0yxnFB
https://amzn.asia/d/cBgQx2Q https://amzn.asia/d/aDdKgzX https://amzn.asia/d/aDdKgzX
賢くInterfaceを使って よりよい設計・開発をしていきましょう👍
ご清聴ありがとうございました🙇