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
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
3k
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.2k
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
[AWS 秋のクラウドオペレーション祭り 2026]AWS DevOps Agentで変わるリリースと運用対応 ~リリース管理機能と Directed actions のご紹介~
furuton
4
1.2k
AIにシークレットを見せない、WSL2で安全な開発環境
yazm
0
180
AI × アーキテクト 第1・2章|生成AIの課題とアーキテクトの素養
daidaidai
0
120
宣言型部分更新は何を解決しどこへ向かうのか
shuta13
1
390
Persisting Massive Data with Rails ~Designing for 60 billion rows, and fighting the bottlenecks~ Railsで挑む大量データ永続化 〜600億件を永続化するための設計とボトルネックとの戦い〜
occhi
0
570
UniFi(ユニファイ)AIカメラの現場活用
ludicmind
1
430
DWH の限界突破! AI エージェント向け爆速リアルタイムデータ基盤 ClickHouse
jozono
1
400
脆弱性診断って、何をしているの? 〜弱点を見つけて、会社の改善につなげるまで〜
keeg
0
900
ai_cording_with_k8s_knowledge.pdf
mochizuki875
1
350
How to Design Configuration for Rails Applications
willnet
0
430
サブエージェントと Claude Mods で作る独自 Advisor ツールの話
kenichiodo
2
140
ブラウザとサーバーから考えるAI時代のフロントエンド監視
shogo4131
3
890
Featured
See All Featured
Facilitating Awesome Meetings
lara
57
7.2k
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
2
410
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
520
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.4k
Odyssey Design
rkendrick25
PRO
2
870
Design in an AI World
tapps
1
350
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
460
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.3k
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
So, you think you're a good person
axbom
PRO
2
2.2k
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
2
2k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.9k
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