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
Object Oriented Training - Session 3
Search
hatelove
July 04, 2012
Technology
11k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Object Oriented Training - Session 3
1. 高內聚、低耦合
2. 單一職責原則
3. 開放/封閉原則
hatelove
July 04, 2012
More Decks by hatelove
See All by hatelove
1. 在沙箱中開發
hatelove
12
3.1k
BDD in .NET - TDD 在實務上的最後一塊拼圖
hatelove
4
2.9k
OO training 基本原則整理
hatelove
2
5.3k
OO training homework 3 review and summary
hatelove
1
11k
OO training homework 2 review and summary
hatelove
1
4.7k
OO training homework 1 review and summary
hatelove
1
8.1k
Object Oriented Training - Session 4
hatelove
1
5.2k
Object Oriented Training - Session 2
hatelove
1
4.9k
Object Oriented Training - Session 1
hatelove
1
8.4k
Other Decks in Technology
See All in Technology
Sets in Go
ramalho
1
1.1k
Rust×eBPFでEDRっぽいものをつくる
sunlife3
1
240
SmartHR Engineering Team Deck
smarthr
1
3.1k
AI-DLC実践録_フルサイクル開発への挑戦
miyuc
0
310
Digitization部 紹介資料
sansan33
PRO
2
7.7k
[potatotips #96] Give Your AI Agent the Flutter Playbook
korodroid
0
120
My broken English still works: speaking at global OSS events
naruoga
0
120
巨大気象データと戦う ― サロゲートモデル学習を高速化する圧縮技術
gpuunite_official
0
160
20260817_生成AIの動向と中学校・高等学校での活用を考える_v1.00_公開用
doradora09
PRO
0
130
【CEDEC2026】Creative Approaches to Localizing the Dialects and Unique Speech of Umamusume: Pretty Derby Characters in English
cygames
PRO
4
26k
AI for Science時代を切り開く、政府の次世代HPC戦略の展望
gpuunite_official
0
110
AIコーディングの次。コードレビューと理解負荷を解消して組織の開発生産性を高める
moongift
PRO
2
2.7k
Featured
See All Featured
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
580
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
430
The untapped power of vector embeddings
frankvandijk
2
1.8k
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
470
WCS-LA-2024
lcolladotor
0
800
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
My Coaching Mixtape
mlcsv
0
250
Writing Fast Ruby
sferik
630
63k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
680
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
4.4k
Color Theory Basics | Prateek | Gurzu
gurzu
0
430
Transcript
Trainer: Joey Chen Date: 2012/06/18 Object Oriented Training – Session
3
- 2 - 高內聚、低耦合
- 3 - 內聚
- 4 - 耦合
- 5 - 高內聚、低耦合
- 6 - 高內聚、低耦合
SOLID
Single Responsibility Principle (SRP) 單一職責原則
- 9 - 多職責
- 10 - 單一職責 • 3 layer • MVC
- 11 - 單一職責 • 避免一個class擁有多個職責 • 避免一個職責散落在多個class中
SOLID
Open Closed Principle (OCP) 開放封閉原則
- 14 - 對擴充開放,對修改封閉
- 15 - 開放封閉原則 • 判斷方式 – 當新增或修改需求時,可以新增class,而使用場景不需改變程 式,即符合開放封閉原則 –
當多一種新的可能時,在同一個class中(非工廠類別),使用if else來修改舊有邏輯,即違反開放封閉原則
- 16 - 案例 – 高內聚、低耦合
- 17 - 回顧
- 18 - 結論 • 抽象思考,釐清職責 • 新增class進行抽換,而不是修改、擴充舊的class • 好的Class特色
– 乾淨、清楚、簡單 – 容易組合與抽換
- 19 - 結論 • 高內聚、低耦合為設計目的 • 原則為設計精神 – 符合原則即可達到目的
• Design patterns – 針對不同需求 – 滿足這些原則的best practice – 達到高內聚、低耦合的目的
- 20 - 作業 – 重構 • 說明 – 決定便利商店的種類,未來可能不是從config讀取
– 資料來源可能會改變 – 未來可能會新增其他便利商店種類 • 注意 – 請將每個Class的職責說明,記錄於Class的summary document 上 – 請將職責獨立的Class,放到Library中,除非該Class是專屬於網 站的職責 – 請參考Selenium的Test Cases
- 21 -
Thanks for your listening Q & A