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
Dinh Quoc Han
March 25, 2023
Technology
0
110
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
41
Laravel Offline Sharing (March 2023) at Ho Chi Minh City, Vietnam
dinhquochan
0
33
Other Decks in Technology
See All in Technology
あの日俺達が夢見たサーバレスアーキテクチャ/the-serverless-architecture-we-dreamed-of
tomoki10
0
460
私なりのAIのご紹介 [2024年版]
qt_luigi
1
120
OpenAIの蒸留機能(Model Distillation)を使用して運用中のLLMのコストを削減する取り組み
pharma_x_tech
4
560
組織に自動テストを書く文化を根付かせる戦略(2024冬版) / Building Automated Test Culture 2024 Winter Edition
twada
PRO
16
4.1k
成果を出しながら成長する、アウトプット駆動のキャッチアップ術 / Output-driven catch-up techniques to grow while producing results
aiandrox
0
330
Storage Browser for Amazon S3
miu_crescent
1
180
オプトインカメラ:UWB測位を応用したオプトイン型のカメラ計測
matthewlujp
0
180
サイバー攻撃を想定したセキュリティガイドライン 策定とASM及びCNAPPの活用方法
syoshie
3
1.3k
非機能品質を作り込むための実践アーキテクチャ
knih
5
1.4k
継続的にアウトカムを生み出し ビジネスにつなげる、 戦略と運営に対するタイミーのQUEST(探求)
zigorou
0
560
Amazon SageMaker Unified Studio(Preview)、Lakehouse と Amazon S3 Tables
ishikawa_satoru
0
150
生成AIをより賢く エンジニアのための RAG入門 - Oracle AI Jam Session #20
kutsushitaneko
4
240
Featured
See All Featured
Producing Creativity
orderedlist
PRO
341
39k
Keith and Marios Guide to Fast Websites
keithpitt
410
22k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.3k
Embracing the Ebb and Flow
colly
84
4.5k
Music & Morning Musume
bryan
46
6.2k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
2
290
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
8
1.2k
Art, The Web, and Tiny UX
lynnandtonic
298
20k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
GraphQLとの向き合い方2022年版
quramy
44
13k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
2k
Why Our Code Smells
bkeepers
PRO
335
57k
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