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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
hatelove
July 04, 2012
Technology
1
11k
Object Oriented Training - Session 3
1. 高內聚、低耦合
2. 單一職責原則
3. 開放/封閉原則
hatelove
July 04, 2012
Tweet
Share
More Decks by hatelove
See All by hatelove
1. 在沙箱中開發
hatelove
12
3k
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.6k
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.8k
Object Oriented Training - Session 1
hatelove
1
8.4k
Other Decks in Technology
See All in Technology
【SLO】"多様な期待値" と向き合ってみた
z63d
2
290
AI Coding Agentの地殻変動 ~ ai-coding.info の定点観測 ~
kotauchisunsun
1
510
Snowflakeデータ基盤で挑むAI活用 〜4年間のDataOpsの基礎をもとに〜
kaz3284
1
330
AIに視覚を与えモバイルアプリケーション開発をより円滑に行う
lycorptech_jp
PRO
1
780
Master Dataグループ紹介資料
sansan33
PRO
1
4.4k
自動テストが巻き起こした開発プロセス・チームの変化 / Impact of Automated Testing on Development Cycles and Team Dynamics
codmoninc
1
980
LINEアプリ開発のための Claude Code活用基盤の構築
lycorptech_jp
PRO
2
1.3k
Security Diaries of an Open Source IAM
ahus1
0
190
マルチロールEMが実践する「組織のレジリエンス」を高めるための組織構造と人材配置戦略
coconala_engineer
2
330
Agentic Codingの実践とチームで導入するための工夫
lycorptech_jp
PRO
0
390
どこで打鍵するのが良い? IaCの実行基盤選定について
nrinetcom
PRO
2
160
AI が Approve する開発フロー / How AI Reviewers Accelerate Our Development
zaimy
1
260
Featured
See All Featured
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.7k
Designing for Timeless Needs
cassininazir
0
150
Six Lessons from altMBA
skipperchong
29
4.2k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
1.7k
Discover your Explorer Soul
emna__ayadi
2
1.1k
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.1k
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
1.8k
Optimizing for Happiness
mojombo
378
71k
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
110
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.3k
Un-Boring Meetings
codingconduct
0
220
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
79
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