SlideShare a Scribd company logo
1 of 56
SOLID
&
Design patterns
Khoi Nguyen
Agenda
● Intro
● SOLID
● Design patterns
○ Decorator
○ Strategy
○ Visitor
● Q & A
Intro
- Design patterns không khó hiểu nếu chúng ta nắm
vững SOLID.
- Design patterns trở nên quen thuộc, gần gũi.
- Design patterns trở thành công cụ giao tiếp.
SOLID
SOLID > Bad Design
SOLID > Good Design
Maintainability
SOLID > Single Responsibility
Support
Maintainability
Reusability
Testability
Eliminate
Rigidity
Fragility
Immobility
SOLID > Single Responsibility
SOLID > Open-Closed
Support
Extensibility
Reusability
Maintainability
Eliminate
Immobility
Viscosity
Rigidity
SOLID > Open-Closed
SOLID > Liskov substitution
Support
Reusability
Extensibility
Maintainability
Eliminate
Fragility
Immobility
Opacity
SOLID > Liskov substitution
SOLID > Interface Segregation
Support
Maintainability
Reusability
Testability
Eliminate
Rigidity
Opacity
Immobility
SOLID > Interface Segregation
SOLID > Dependency Inversion
Support
Extensibility
Maintainability
Testability
Eliminate
Immobility
Viscosity
Rigidity
SOLID > Dependency Inversion
SOLID > Dependency Inversion
SOLID > Dependency Inversion
SOLID > Dependency Inversion
SOLID > Dependency Inversion
Advices
● A class should have only one reason to change.
● Favor Composition over inheritance
● Program to interfaces, not implementations.
● DRY Principle: Don't Repeat Yourself
Design Pattern
Design patterns are typical solutions to common problems in software design
Design Pattern
https://gist.github.com/lolzballs/2152bc0f31ee0286b722
Design Pattern > Diagram
Decorator Pattern
Decorator Pattern
Attach additional responsibility dynamically during runtime.
Trong đầm gì đẹp bằng sen
Lá xanh bông trắng lại chen nhụy vàng
Decorator Pattern
Decorator Pattern > Example
Decorator Pattern > Example
Decorator Pattern > Example
Decorator Pattern > Example
Decorator Pattern > Example
Decorator Pattern > Real Example
Bánh + nước
Decorator Pattern > Real Example
Cước
Wifi
Dịch vụ
Dịch_vụ_tùy_chọn
Strategy Pattern
Strategy Pattern
Define a family of algorithms, encapsulate each one, and make them interchangeable.
Con gà cục tác: “lá chanh”
Con lợn ủn ỉn “Mua hành cho tôi”
Con chó khóc đứng khóc ngồi:
“Bà ơi đi chợ mua tôi đồng riềng”.
Strategy Pattern > Diagram
Món chính
(gà, heo, chó)
Lá chanh Củ hành Củ riềng
Strategy Pattern
A
B C
G
F
E
D
K
J
I
H L
Strategy Pattern > Example
Strategy Pattern > Example
Strategy Pattern > Example
Strategy Pattern > Real Example
Strategy Pattern > Real Example
Đơn Hàng
Tín dụng Momo Bitcoin
Visitor Pattern
Visitor Pattern
A way of separating an algorithm from an object structure on which it operates.Visitor lets you add new
operations to existent object structures without modifying the structures.
Dẫn lang nhập thất
Visitor Pattern
Phòng khách Nhà bếp Sói
Visitor Pattern > Example
Visitor Pattern > Example
Visitor Pattern > Example
Visitor Pattern > Example
Visitor Pattern > Real Example
Visitor Pattern > Real Example
Mô tả SP Bình luận Đánh giá SP
Recap
● SOLID
● Design patterns
○ Decorator
○ Strategy
○ Visitor
● Design patterns & ca dao tục ngữ
● Caution
○ Use the right tool for the job
Example on Github
https://github.com/khoiquyenvn/designpattern
Q & A
Thanks!
Contact us:
KMS Technology
2 Tản Viên, P.2, Q.Tân Bình
khoimnguyen@kms-technology.com
www.kms-technology.com

More Related Content

Similar to SOLID & Design patterns.pptx

Research & Design: Finding the Perfect Blend
Research & Design: Finding the Perfect BlendResearch & Design: Finding the Perfect Blend
Research & Design: Finding the Perfect BlendKimberly Dowd
 
The business case for contributing code
The business case for contributing codeThe business case for contributing code
The business case for contributing codeZivtech, LLC
 
Research & Design: Collaboration that Delivers Person-Centered Solutions - We...
Research & Design: Collaboration that Delivers Person-Centered Solutions - We...Research & Design: Collaboration that Delivers Person-Centered Solutions - We...
Research & Design: Collaboration that Delivers Person-Centered Solutions - We...Mad*Pow
 
SOLID design principles in Ruby
SOLID design principles in RubySOLID design principles in Ruby
SOLID design principles in RubyAnil Wadghule
 
Comprehensive Validation with Laravel 4
Comprehensive Validation with Laravel 4Comprehensive Validation with Laravel 4
Comprehensive Validation with Laravel 4Kirk Bushell
 
Monktoberfest Fast Delivery
Monktoberfest Fast DeliveryMonktoberfest Fast Delivery
Monktoberfest Fast DeliveryAdrian Cockcroft
 
Event Design - Art with a Strategy
Event Design - Art with a StrategyEvent Design - Art with a Strategy
Event Design - Art with a StrategyHilary Howes, CMG
 
Grid Systems in Graphic Design by ADMEC Multimedia Institute
Grid Systems in Graphic Design by ADMEC Multimedia InstituteGrid Systems in Graphic Design by ADMEC Multimedia Institute
Grid Systems in Graphic Design by ADMEC Multimedia InstituteRavi Bhadauria
 
Its not about the tooling
Its not about the toolingIts not about the tooling
Its not about the toolingBram Vogelaar
 
What is Design Thinking?
What is Design Thinking?What is Design Thinking?
What is Design Thinking?David Terrar
 
Devops its not about the tooling
Devops its not about the toolingDevops its not about the tooling
Devops its not about the toolingBram Vogelaar
 
Devops 101 QA with Kris Buytaert
Devops 101 QA  with Kris BuytaertDevops 101 QA  with Kris Buytaert
Devops 101 QA with Kris BuytaertKris Buytaert
 
ATDD - Agile Testing
ATDD -  Agile Testing ATDD -  Agile Testing
ATDD - Agile Testing chzy
 
What is a UX Strategy?
What is a UX Strategy?What is a UX Strategy?
What is a UX Strategy?LMarine
 

Similar to SOLID & Design patterns.pptx (20)

Research & Design: Finding the Perfect Blend
Research & Design: Finding the Perfect BlendResearch & Design: Finding the Perfect Blend
Research & Design: Finding the Perfect Blend
 
The business case for contributing code
The business case for contributing codeThe business case for contributing code
The business case for contributing code
 
10 Commandments of UX
10 Commandments of UX10 Commandments of UX
10 Commandments of UX
 
Research & Design: Collaboration that Delivers Person-Centered Solutions - We...
Research & Design: Collaboration that Delivers Person-Centered Solutions - We...Research & Design: Collaboration that Delivers Person-Centered Solutions - We...
Research & Design: Collaboration that Delivers Person-Centered Solutions - We...
 
Design Principles
Design PrinciplesDesign Principles
Design Principles
 
SOLID design principles in Ruby
SOLID design principles in RubySOLID design principles in Ruby
SOLID design principles in Ruby
 
Comprehensive Validation with Laravel 4
Comprehensive Validation with Laravel 4Comprehensive Validation with Laravel 4
Comprehensive Validation with Laravel 4
 
Monktoberfest Fast Delivery
Monktoberfest Fast DeliveryMonktoberfest Fast Delivery
Monktoberfest Fast Delivery
 
Event Design - Art with a Strategy
Event Design - Art with a StrategyEvent Design - Art with a Strategy
Event Design - Art with a Strategy
 
Grid Systems in Graphic Design by ADMEC Multimedia Institute
Grid Systems in Graphic Design by ADMEC Multimedia InstituteGrid Systems in Graphic Design by ADMEC Multimedia Institute
Grid Systems in Graphic Design by ADMEC Multimedia Institute
 
Its not about the tooling
Its not about the toolingIts not about the tooling
Its not about the tooling
 
What is Design Thinking?
What is Design Thinking?What is Design Thinking?
What is Design Thinking?
 
Designthinking-prototype
Designthinking-prototypeDesignthinking-prototype
Designthinking-prototype
 
Devops its not about the tooling
Devops its not about the toolingDevops its not about the tooling
Devops its not about the tooling
 
Devops 101 QA with Kris Buytaert
Devops 101 QA  with Kris BuytaertDevops 101 QA  with Kris Buytaert
Devops 101 QA with Kris Buytaert
 
Creativity
CreativityCreativity
Creativity
 
ATDD - Agile Testing
ATDD -  Agile Testing ATDD -  Agile Testing
ATDD - Agile Testing
 
Design thinking
Design thinkingDesign thinking
Design thinking
 
Berkenalan dengan Design Thinking
Berkenalan dengan Design ThinkingBerkenalan dengan Design Thinking
Berkenalan dengan Design Thinking
 
What is a UX Strategy?
What is a UX Strategy?What is a UX Strategy?
What is a UX Strategy?
 

Recently uploaded

%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfonteinmasabamasaba
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...masabamasaba
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareJim McKeeth
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in sowetomasabamasaba
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburgmasabamasaba
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...masabamasaba
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...chiefasafspells
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfonteinmasabamasaba
 

Recently uploaded (20)

%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security Program
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 

SOLID & Design patterns.pptx

Editor's Notes

  1. Công cụ để biểu đạt (nói rất ngắn gọn, nhưng khả năng diễn đạt cao) Lý do gây trở ngại cho việc hiểu DP là do ko hiểu SOLID Design pattern trở thành thân thuộc, gần gũi Xa hơn, hi vọng mọi người có thể sử dụng DP như công cụ giao tiếp công việc với nhau hằng ngày 3 patterns chuyên dùng để đối phó với vấn đề change requirement + mở rộng tính năng
  2. Là 1 phương pháp lập trình Chia chương trình thành các đối tượng và các đối tượng này tương tác với nhau
  3. Che dấu sự phức tạp
  4. Che dấu để bảo vệ tính đúng đắn của dữ liệu (internal state)
  5. Reuse 100% đối tượng đã có sẵn
  6. Ở thời điểm thực thi, mới xác định sẽ là đối tượng nào từ đó mới xác định cách thức
  7. Viết tắt của 5 nguyên lý trong thiết kế phần mềm theo hướng OOP Bộ nguyên tắc thiết kế Giống như kim chỉ nam Như nguyên tắc tham gia giao thông, có hàng trăm biển báo nhưng chỉ có 4 nguyên tắc. Nguyên tắc thì rất ngắn gọn Nếu tuân thủ đúng sẽ tạo ra đc tính dễ hiểu, dễ đọc > dễ bảo trì, sửa chữa, mở rộng
  8. Maintainability: dễ đọc, dễ hiểu, tính gắn kết, nhất quán. Thường đc đo bằng khoảng thời gian mà bạn nghĩ để thay đổi một thứ gì đó so với thực tế. Reusability: có thể tái sử dụng đc một vài component của project cũ thay vì phải đem toàn bộ component qua proj mới. Ví dụ: payment Extensibility: khả năng mở rộng, phát triển thêm tính năng mới, mà với chi phí thay đổi là thấp nhất có thể Testability: Unit test Efficiency: sử dụng tài nguyên hiệu quả, tổng ko đổi
  9. Hành vi Consistent xuyên suốt trong program Xác định rõ ràng nhiệm vụ của mỗi class => khi cần thay đổi thì số chỗ cần phải thay đổi là ít nhất lead to god class, domino theory if a change to the App1 causes the common class, that change may force us to rebuild, retest, and redeploy the App2. If we forget to do this, that application may break in unpredictable ways.
  10. Single responsibility in a bounded context. Ex : a car engine
  11. Support cho tính extensibility, bằng cách thêm mới thành phần thay vì thay đổi cái cũ. An toàn hơn & tiết kiệm hơn Chương trình viết ra là để thay đổi > nên thay vì debate chúng ta sẽ tìm cách làm cho việc thay đổi dễ dàng hơn cách duy nhất để thêm tính năng mới là modify class cũ > mất tính đúng đắn của class cũ > test lại designer to apply abstraction to those parts of the program that the designer feels are going to be subject to change. 3 patterns đc giới thiệu hôm nay sẽ liên quan đến nguyên lý này Abstraction is key
  12. Chương trình viết ra là để thay đổi > nên thay vì debate chúng ta sẽ tìm cách làm cho việc thay đổi dễ dàng hơn Abstraction is key Ex: thiết bị lọc nước Why: cách duy nhất để thêm tính năng mới là modify class cũ > mất tính đúng đắn của class cũ > test lại Reusability & Maintainability designer to apply abstraction to those parts of the program that the designer feels are going to be subject to change. 3 patterns đc giới thiệu hôm nay sẽ liên quan đến nguyên lý này
  13. Là nguyên lý đảm bảo cho tính kế thừa đúng Logic trong thế giới lập trình và logic trong thực tế đôi khi không đồng nhất với nhau. Ex: chim cánh cụt why : It may lead to violate o/c principle (add new subclass > have to modify base class) Cause unpredictable error
  14. Logic trong thế giới lập trình và logic trong thực tế đôi khi không đồng nhất với nhau. Ex: chim cánh cụt why : It may lead to violate o/c principle (add new subclass > have to modify base class) Cause unpredictable error
  15. Kế thừa class vs implement interface Tách nhỏ interface sao cho đủ chức năng, ko quá lớn > tạo thành gánh nặng, ko quá nhỏ > phân mảnh Không buộc client phải implement những gì mà họ ko sử dụng SR vs IS Ex: Bánh trung thu
  16. Tách nhỏ interface sao cho đủ chức năng, ko quá lớn > tạo thành gánh nặng, ko quá nhỏ > phân mảnh Không buộc client phải implement những gì mà họ ko sử dụng SR from designer view vs IS client view Ex: Bánh trung thu
  17. là cái khung chương trình, mình có thể lập trình trước, sau đó mới lắp các thành phần cụ thể vào High level module should not depend on low level module, both should depend on abstraction. Abstraction should not depend on detail, detail should depend on abstraction. Định nghĩa cách thức giao tiếp trước
  18. High level module should not depend on low level module, both should depend on abstraction. Abstraction should not depend on detail, detail should depend on abstraction. Định nghĩa cách thức giao tiếp trước
  19. High level module should not depend on low level module, both should depend on abstraction. Abstraction should not depend on detail, detail should depend on abstraction. Định nghĩa cách thức giao tiếp trước
  20. High level module should not depend on low level module, both should depend on abstraction. Abstraction should not depend on detail, detail should depend on abstraction. Định nghĩa cách thức giao tiếp trước
  21. High level module should not depend on low level module, both should depend on abstraction. Abstraction should not depend on detail, detail should depend on abstraction. Định nghĩa cách thức giao tiếp trước
  22. DIP means that you program against an abstraction. IOC means that somebody else is responsible for getting the implementation for the given abstraction (eliminate new keyword) You can use an IoC Container as a Service Locator > you couple them all to the Service Locator IoC Container you use Dependency Injection > auto-wiring
  23. 3 patterns comply with open/close principle.
  24. Sử dụng đúng công cụ vào đúng hoàn cảnh, tránh việc nhồi nhét pattern vào project > gánh nặng ko cần thiết.
  25. 3 phương tiện truyền tải: Câu ca dao tục ngữ, đi kèm hình ảnh, class Diagram của pattern. kèm chú thích tương ứng với câu ca dao Câu chuyện công ty xà bần, yêu cầu từ khách hàng, class diagram và chú thích tương ứng Code demo còn bông nào khác mà khen bây giờ? :D
  26. Nồi đồng nấu ốc, nồi đất nấu ếch Ăn cơm Tàu, ở nhà Tây, lấy vợ Nhật Đi với bụt mặc áo cà sa, đi với ma mặc áo giấy
  27. Dẫn sói vào nhà Cõng rắn cắn gà nhà Rước voi về giày mã tổ Áp dụng cho các cấu trúc dữ liệu phức tạp, pattern dùng để tách hành động ra khỏi cấu trúc đối tượng và xem nó như khách, Nhiệm vụ của cấu trúc dữ liệu chỉ là “dẫn” khách đi qua các thành phần trong cấu trúc của mình