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
Laravel Vietnam Meetup 2022: Your code is simpl...
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Dinh Quoc Han
March 25, 2023
Technology
0
120
Laravel Vietnam Meetup 2022: Your code is simplify or complexity?
Laravel Vietnam Meetup (August 2022) at Ho Chi Minh City, Vietnam
Dinh Quoc Han
March 25, 2023
Tweet
Share
More Decks by Dinh Quoc Han
See All by Dinh Quoc Han
Laravel Live Vietnam 2022: Laravel Eloquent Performance
dinhquochan
0
59
Laravel Offline Sharing (March 2023) at Ho Chi Minh City, Vietnam
dinhquochan
0
54
Other Decks in Technology
See All in Technology
FastMCP OAuth Proxy with Cognito
hironobuiga
3
200
「コントロールの三分法」で考える「コト」への向き合い方 / phperkaigi2026
blue_goheimochi
0
150
Phase11_戦略的AI経営
overflowinc
0
1.5k
Bill One 開発エンジニア 紹介資料
sansan33
PRO
5
18k
AIエージェント×GitHubで実現するQAナレッジの資産化と業務活用 / QA Knowledge as Assets with AI Agents & GitHub
tknw_hitsuji
0
230
Phase03_ドキュメント管理
overflowinc
0
2.5k
20260320_JaSST26_Tokyo_登壇資料.pdf
mura_shin
0
120
テストプロセスにおけるAI活用 :人間とAIの共存
hacomono
PRO
0
160
Phase02_AI座学_応用
overflowinc
0
2.8k
20年以上続く PHP 大規模プロダクトを Kubernetes へ ── クラウド基盤刷新プロジェクトの4年間
oogfranz
PRO
0
240
Blue/Green Deployment を用いた PostgreSQL のメジャーバージョンアップ
kkato1
0
130
From Senior to Staff : To infinity and beyond !
kuahyeow
0
110
Featured
See All Featured
Raft: Consensus for Rubyists
vanstee
141
7.4k
A Modern Web Designer's Workflow
chriscoyier
698
190k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.6k
GraphQLの誤解/rethinking-graphql
sonatard
75
11k
Information Architects: The Missing Link in Design Systems
soysaucechin
0
840
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.2k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.2k
The Limits of Empathy - UXLibs8
cassininazir
1
270
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.3k
Optimising Largest Contentful Paint
csswizardry
37
3.6k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
1
1.5k
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
360
Transcript
Your Code Is SIMPLIFY Or COMPLEXITY? with Dinh Quoc Han
Code Của Bạn ĐƠN GIẢN Hay PHỨC TẠP? với Đinh
Quốc Hân
Who Am I? PHP Lover, Artisan 6 years experience Currently
working at SHIFT ASIA Admin at Laravel Viet Nam
Overview 1. Problems 2. Coding Standards 3. CRUD 4. Complexity?
5. Q&A
1. Problems!
2. Coding Standards
PSR-12
None
None
How to follow PSR-12?
None
PSR-12
composer require --dev laravel/pint
3. CRUD Create - Read - Update - Delete 😎
How Many?
M-V-C
M-V-C but by Packages
Domain Oriented Design Not ‘DDD’ - Domain Driven Design 🤣
…
Basic Example
routes/web.php
app/Http/Controllers/UserController.php
app/Http/Controllers/UserController.php
Write all business logic in controller?
None
Why?
Controller should hold ZERO logic!
Controller only bring logic together!
Easy apply design patterns, structures!
Easy to reuse, maintenance, testing
1. Fat Model - Thin Controller
None
None
None
2. Repository Class or Service Class
None
None
3. Actions/Commands Class (CQRS)
None
None
4. Together
Example From Laravel
None
None
Next: Controller!
Cruddy by Design Adam Wathan
"More controllers doing less work obviates need for many other
fancy patterns!" David Heinemeier Hansson - Creator of RoR
7 Standard Actions in Laravel
1. Index 2. Create 3. Store 4. Show 5. Edit
6. Update 7. Destroy
NEVER write CUSTOM ACTION
None
None
None
Tip #1: Nested Resource? Create New Controller
None
None
Tip #2: Edited Dependently? Create New Controller
None
None
Tip #3: Touches Pivot Records? Create New Controller
None
None
Tip #4: Transitions State? Create New Controller
Example From Laravel
None
None
Or Single Action Controller? Invokable Controller
None
None
4. Complexity?
YAGNI "You aren't gonna need it"
Back To The BASIC
app/Http/Controllers/UserController.php
1 Phút Quảng Cáo!
None
Thank You Q&A