SlideShare a Scribd company logo
1 of 28
Download to read offline
Developer	
  Exchange	
  Group
深入淺出設計模式#5:	
  
轉接器模式與表象模式	
  
Prepare	
  by	
  Sean	
  Hsieh	
  
Adapter	
  pa?ern
Scene
•  New	
  interface	
  doesn’t	
  work	
  
–  New	
  vendor	
  designed	
  their	
  interfaces	
  differently	
  than	
  the	
  
last	
  vendor.	
  
Data	
  source:	
  Head	
  first	
  design	
  pa?ern
How	
  to	
  use	
  old	
  design?
•  An	
  adapter	
  designed	
  
–  Designed	
  an	
  interfaces	
  to	
  adapter	
  the	
  old	
  interface.	
  
Data	
  source:	
  Head	
  first	
  design	
  pa?ern
Example	
  of	
  adapter	
  class
Duck	
  
quack()	
  
Fly()
Turkey	
  
gobble()	
  
Fly()
Data	
  source:	
  Head	
  first	
  design	
  pa?ern
Example	
  of	
  using	
  adapter	
  class
Data	
  source:	
  Head	
  first	
  design	
  pa?ern
DefiniLon	
  of	
  adapter	
  pa?ern
•  Adapter	
  pa8ern	
  	
  
–  When	
  you	
  need	
  to	
  use	
  an	
  exisLng	
  class	
  and	
  interface	
  is	
  not	
  the	
  one	
  you	
  need	
  
–  Usage:	
  
•  converts	
  the	
  interface	
  of	
  a	
  class	
  into	
  another	
  interface	
  the	
  clients	
  except
Data	
  source:	
  Head	
  first	
  design	
  pa?ern
Kinds	
  of	
  adapter	
  pa?ern
•  1.	
  Object	
  Adapter	
  
Data	
  source:	
  Head	
  first	
  design	
  pa?ern
Kinds	
  of	
  adapter	
  pa?ern	
  (cont.)
•  2.	
  Class	
  Adapter	
  
–  Class	
  adapter	
  use	
  mulLple	
  inheritance,	
  so	
  you	
  can’t	
  do	
  it	
  in	
  
JAVA	
  
Data	
  source:	
  Head	
  first	
  design	
  pa?ern
Note
•  1.	
  We	
  could	
  use	
  adapter	
  with	
  any	
  subclass	
  of	
  
the	
  adaptee.	
  
•  2.	
  Use	
  adapter	
  to	
  decouple	
  the	
  client	
  from	
  the	
  
implemented	
  interface.	
  
•  3.	
  You	
  can	
  rework	
  all	
  your	
  client-­‐side	
  calls	
  to	
  
the	
  interface,	
  which	
  would	
  result	
  in	
  a	
  lot	
  of	
  
invesLgaLve	
  work	
  and	
  code	
  changes.
Facade	
  pa?ern	
  
An	
  adapter	
  hold	
  two	
  or	
  more	
  adaptee
scene
•  Home	
  theater	
  
–  We	
  have	
  to	
  do	
  many	
  thing	
  before	
  watching	
  movie
Data	
  source:	
  Head	
  first	
  design	
  pa?ern
How	
  to	
  simplify	
  these	
  procedure?	
  
•  Facade	
  pa8ern	
  
–  When	
  you	
  need	
  to	
  simplify	
  and	
  unify	
  a	
  large	
  interface	
  or	
  complex	
  set	
  of	
  
interfaces	
  
–  Usage:	
  
•  Create	
  a	
  facade	
  class	
  with	
  a	
  simplified	
  method.
Data	
  source:	
  Head	
  first	
  design	
  pa?ern
Example	
  of	
  facade	
  pa?ern	
  	
  
Data	
  source:	
  Head	
  first	
  design	
  pa?ern
Example	
  of	
  facade	
  pa?ern	
  (cont.)	
  
Data	
  source:	
  Head	
  first	
  design	
  pa?ern
Example	
  of	
  using	
  facade	
  pa?ern
Data	
  source:	
  Head	
  first	
  design	
  pa?ern
DefiniLon	
  of	
  facade	
  pa?ern
•  Facade	
  pa8ern	
  provide	
  a	
  unified	
  interface	
  to	
  a	
  
set	
  of	
  interfaces	
  in	
  a	
  subsystem.	
  
Data	
  source:	
  Head	
  first	
  design	
  pa?ern
Note
•  1.	
  Facade	
  don’t	
  “encapsulate”	
  the	
  subsystem	
  
classes;	
  they	
  merely	
  provide	
  a	
  simplified	
  
interface	
  to	
  their	
  funcLonality.	
  
•  2.	
  Facade	
  also	
  allows	
  you	
  decouple	
  your	
  client	
  
implementaLon	
  from	
  any	
  one	
  subsystem.
The	
  principle	
  of	
  Least	
  knowledge
•  Talk	
  only	
  to	
  your	
  immediate	
  friends.	
  
•  Also	
  called	
  Law	
  of	
  Demeter	
  
•  Ex:
Data	
  source:	
  Head	
  first	
  design	
  pa?ern
More
Image	
  editor
FuncLons	
  of	
  image	
  editor	
  
Class	
  diagram	
  of	
  image	
  editor
Wallpaper	
  Product
Class	
  diagram	
  of	
  Wallpaper	
  Product
3D	
  View
Class	
  diagram	
  of	
  Wallpaper	
  Product
轉接器模式與表象模式

More Related Content

Viewers also liked

可抽換元件設計模式
可抽換元件設計模式可抽換元件設計模式
可抽換元件設計模式Pete Chen
 
設計模式的解析與活用 -開拓視野
設計模式的解析與活用 -開拓視野設計模式的解析與活用 -開拓視野
設計模式的解析與活用 -開拓視野Ted Liang
 
Designs, Lessons and Advice from Building Large Distributed Systems
Designs, Lessons and Advice from Building Large Distributed SystemsDesigns, Lessons and Advice from Building Large Distributed Systems
Designs, Lessons and Advice from Building Large Distributed SystemsChris Huang
 
重構—改善既有程式的設計(chapter 2,3)
重構—改善既有程式的設計(chapter 2,3)重構—改善既有程式的設計(chapter 2,3)
重構—改善既有程式的設計(chapter 2,3)Chris Huang
 
Entity Framework實戰
Entity Framework實戰Entity Framework實戰
Entity Framework實戰國昭 張
 
[教材] 例外處理設計與重構實作班201309
[教材] 例外處理設計與重構實作班201309[教材] 例外處理設計與重構實作班201309
[教材] 例外處理設計與重構實作班201309teddysoft
 
購物車程式架構簡介
購物車程式架構簡介購物車程式架構簡介
購物車程式架構簡介Jace Ju
 
重構—改善既有程式的設計(chapter 4,5)
重構—改善既有程式的設計(chapter 4,5)重構—改善既有程式的設計(chapter 4,5)
重構—改善既有程式的設計(chapter 4,5)Chris Huang
 
那一夜我們說Pattern design patterns 20周年-published
那一夜我們說Pattern design patterns 20周年-published那一夜我們說Pattern design patterns 20周年-published
那一夜我們說Pattern design patterns 20周年-publishedteddysoft
 
重構—改善既有程式的設計(chapter 1)
重構—改善既有程式的設計(chapter 1)重構—改善既有程式的設計(chapter 1)
重構—改善既有程式的設計(chapter 1)Chris Huang
 
常見設計模式介紹
常見設計模式介紹常見設計模式介紹
常見設計模式介紹Jace Ju
 
設計模式的解析與活用讀後心得
設計模式的解析與活用讀後心得設計模式的解析與活用讀後心得
設計模式的解析與活用讀後心得昱劭 劉
 
模式入門第一堂課: 30分鐘寫出一個模式
模式入門第一堂課: 30分鐘寫出一個模式模式入門第一堂課: 30分鐘寫出一個模式
模式入門第一堂課: 30分鐘寫出一個模式teddysoft
 
用十分鐘 學會《資料結構、演算法和計算理論》
用十分鐘  學會《資料結構、演算法和計算理論》用十分鐘  學會《資料結構、演算法和計算理論》
用十分鐘 學會《資料結構、演算法和計算理論》鍾誠 陳鍾誠
 
用十分鐘搞懂《離散數學》
用十分鐘搞懂《離散數學》用十分鐘搞懂《離散數學》
用十分鐘搞懂《離散數學》鍾誠 陳鍾誠
 
用十分鐘搞懂 《系統分析、軟體工程、專案管理與設計模式》
用十分鐘搞懂   《系統分析、軟體工程、專案管理與設計模式》用十分鐘搞懂   《系統分析、軟體工程、專案管理與設計模式》
用十分鐘搞懂 《系統分析、軟體工程、專案管理與設計模式》鍾誠 陳鍾誠
 

Viewers also liked (20)

裝飾者模式
裝飾者模式 裝飾者模式
裝飾者模式
 
策略模式
策略模式 策略模式
策略模式
 
獨體模式
獨體模式 獨體模式
獨體模式
 
觀察者模式
觀察者模式 觀察者模式
觀察者模式
 
可抽換元件設計模式
可抽換元件設計模式可抽換元件設計模式
可抽換元件設計模式
 
設計模式的解析與活用 -開拓視野
設計模式的解析與活用 -開拓視野設計模式的解析與活用 -開拓視野
設計模式的解析與活用 -開拓視野
 
Designs, Lessons and Advice from Building Large Distributed Systems
Designs, Lessons and Advice from Building Large Distributed SystemsDesigns, Lessons and Advice from Building Large Distributed Systems
Designs, Lessons and Advice from Building Large Distributed Systems
 
重構—改善既有程式的設計(chapter 2,3)
重構—改善既有程式的設計(chapter 2,3)重構—改善既有程式的設計(chapter 2,3)
重構—改善既有程式的設計(chapter 2,3)
 
Entity Framework實戰
Entity Framework實戰Entity Framework實戰
Entity Framework實戰
 
[教材] 例外處理設計與重構實作班201309
[教材] 例外處理設計與重構實作班201309[教材] 例外處理設計與重構實作班201309
[教材] 例外處理設計與重構實作班201309
 
購物車程式架構簡介
購物車程式架構簡介購物車程式架構簡介
購物車程式架構簡介
 
重構—改善既有程式的設計(chapter 4,5)
重構—改善既有程式的設計(chapter 4,5)重構—改善既有程式的設計(chapter 4,5)
重構—改善既有程式的設計(chapter 4,5)
 
那一夜我們說Pattern design patterns 20周年-published
那一夜我們說Pattern design patterns 20周年-published那一夜我們說Pattern design patterns 20周年-published
那一夜我們說Pattern design patterns 20周年-published
 
重構—改善既有程式的設計(chapter 1)
重構—改善既有程式的設計(chapter 1)重構—改善既有程式的設計(chapter 1)
重構—改善既有程式的設計(chapter 1)
 
常見設計模式介紹
常見設計模式介紹常見設計模式介紹
常見設計模式介紹
 
設計模式的解析與活用讀後心得
設計模式的解析與活用讀後心得設計模式的解析與活用讀後心得
設計模式的解析與活用讀後心得
 
模式入門第一堂課: 30分鐘寫出一個模式
模式入門第一堂課: 30分鐘寫出一個模式模式入門第一堂課: 30分鐘寫出一個模式
模式入門第一堂課: 30分鐘寫出一個模式
 
用十分鐘 學會《資料結構、演算法和計算理論》
用十分鐘  學會《資料結構、演算法和計算理論》用十分鐘  學會《資料結構、演算法和計算理論》
用十分鐘 學會《資料結構、演算法和計算理論》
 
用十分鐘搞懂《離散數學》
用十分鐘搞懂《離散數學》用十分鐘搞懂《離散數學》
用十分鐘搞懂《離散數學》
 
用十分鐘搞懂 《系統分析、軟體工程、專案管理與設計模式》
用十分鐘搞懂   《系統分析、軟體工程、專案管理與設計模式》用十分鐘搞懂   《系統分析、軟體工程、專案管理與設計模式》
用十分鐘搞懂 《系統分析、軟體工程、專案管理與設計模式》
 

Similar to 轉接器模式與表象模式

APEX Application Lifecycle and Deployment 20220714.pdf
APEX Application Lifecycle and Deployment 20220714.pdfAPEX Application Lifecycle and Deployment 20220714.pdf
APEX Application Lifecycle and Deployment 20220714.pdfRichard Martens
 
Powering Custom Apps at Facebook using Spark Script Transformation
Powering Custom Apps at Facebook using Spark Script TransformationPowering Custom Apps at Facebook using Spark Script Transformation
Powering Custom Apps at Facebook using Spark Script TransformationDatabricks
 
Cassandra Summit Sept 2015 - Real Time Advanced Analytics with Spark and Cass...
Cassandra Summit Sept 2015 - Real Time Advanced Analytics with Spark and Cass...Cassandra Summit Sept 2015 - Real Time Advanced Analytics with Spark and Cass...
Cassandra Summit Sept 2015 - Real Time Advanced Analytics with Spark and Cass...Chris Fregly
 
Terraform modules restructured
Terraform modules restructuredTerraform modules restructured
Terraform modules restructuredAmi Mahloof
 
Terraform Modules Restructured
Terraform Modules RestructuredTerraform Modules Restructured
Terraform Modules RestructuredDoiT International
 
Building and deploying LLM applications with Apache Airflow
Building and deploying LLM applications with Apache AirflowBuilding and deploying LLM applications with Apache Airflow
Building and deploying LLM applications with Apache AirflowKaxil Naik
 
Strata NY 2017 Parquet Arrow roadmap
Strata NY 2017 Parquet Arrow roadmapStrata NY 2017 Parquet Arrow roadmap
Strata NY 2017 Parquet Arrow roadmapJulien Le Dem
 
Who pulls the strings?
Who pulls the strings?Who pulls the strings?
Who pulls the strings?Ronny
 
The columnar roadmap: Apache Parquet and Apache Arrow
The columnar roadmap: Apache Parquet and Apache ArrowThe columnar roadmap: Apache Parquet and Apache Arrow
The columnar roadmap: Apache Parquet and Apache ArrowDataWorks Summit
 
01-01-2017 This section will lay out the implementation plan o.docx
01-01-2017 This section will lay out the implementation plan o.docx01-01-2017 This section will lay out the implementation plan o.docx
01-01-2017 This section will lay out the implementation plan o.docxhoney725342
 
Onion Architecture with S#arp
Onion Architecture with S#arpOnion Architecture with S#arp
Onion Architecture with S#arpGary Pedretti
 
Developing Lightning Components for Communities.pptx
Developing Lightning Components for Communities.pptxDeveloping Lightning Components for Communities.pptx
Developing Lightning Components for Communities.pptxDmitry Vinnik
 
Extending Apache Spark SQL Data Source APIs with Join Push Down with Ioana De...
Extending Apache Spark SQL Data Source APIs with Join Push Down with Ioana De...Extending Apache Spark SQL Data Source APIs with Join Push Down with Ioana De...
Extending Apache Spark SQL Data Source APIs with Join Push Down with Ioana De...Databricks
 
Zend Framework 2, What's new, Confoo 2011
Zend Framework 2, What's new, Confoo 2011Zend Framework 2, What's new, Confoo 2011
Zend Framework 2, What's new, Confoo 2011Bachkoutou Toutou
 
ApacheCon North America 2018: Creating Spark Data Sources
ApacheCon North America 2018: Creating Spark Data SourcesApacheCon North America 2018: Creating Spark Data Sources
ApacheCon North America 2018: Creating Spark Data SourcesJayesh Thakrar
 
Getting up to speed with Kafka Connect: from the basics to the latest feature...
Getting up to speed with Kafka Connect: from the basics to the latest feature...Getting up to speed with Kafka Connect: from the basics to the latest feature...
Getting up to speed with Kafka Connect: from the basics to the latest feature...HostedbyConfluent
 

Similar to 轉接器模式與表象模式 (20)

APEX Application Lifecycle and Deployment 20220714.pdf
APEX Application Lifecycle and Deployment 20220714.pdfAPEX Application Lifecycle and Deployment 20220714.pdf
APEX Application Lifecycle and Deployment 20220714.pdf
 
Powering Custom Apps at Facebook using Spark Script Transformation
Powering Custom Apps at Facebook using Spark Script TransformationPowering Custom Apps at Facebook using Spark Script Transformation
Powering Custom Apps at Facebook using Spark Script Transformation
 
Cassandra Summit Sept 2015 - Real Time Advanced Analytics with Spark and Cass...
Cassandra Summit Sept 2015 - Real Time Advanced Analytics with Spark and Cass...Cassandra Summit Sept 2015 - Real Time Advanced Analytics with Spark and Cass...
Cassandra Summit Sept 2015 - Real Time Advanced Analytics with Spark and Cass...
 
Terraform modules restructured
Terraform modules restructuredTerraform modules restructured
Terraform modules restructured
 
Terraform Modules Restructured
Terraform Modules RestructuredTerraform Modules Restructured
Terraform Modules Restructured
 
Building and deploying LLM applications with Apache Airflow
Building and deploying LLM applications with Apache AirflowBuilding and deploying LLM applications with Apache Airflow
Building and deploying LLM applications with Apache Airflow
 
Strata NY 2017 Parquet Arrow roadmap
Strata NY 2017 Parquet Arrow roadmapStrata NY 2017 Parquet Arrow roadmap
Strata NY 2017 Parquet Arrow roadmap
 
Who pulls the strings?
Who pulls the strings?Who pulls the strings?
Who pulls the strings?
 
The columnar roadmap: Apache Parquet and Apache Arrow
The columnar roadmap: Apache Parquet and Apache ArrowThe columnar roadmap: Apache Parquet and Apache Arrow
The columnar roadmap: Apache Parquet and Apache Arrow
 
01-01-2017 This section will lay out the implementation plan o.docx
01-01-2017 This section will lay out the implementation plan o.docx01-01-2017 This section will lay out the implementation plan o.docx
01-01-2017 This section will lay out the implementation plan o.docx
 
Onion Architecture with S#arp
Onion Architecture with S#arpOnion Architecture with S#arp
Onion Architecture with S#arp
 
Developing Lightning Components for Communities.pptx
Developing Lightning Components for Communities.pptxDeveloping Lightning Components for Communities.pptx
Developing Lightning Components for Communities.pptx
 
Extending Apache Spark SQL Data Source APIs with Join Push Down with Ioana De...
Extending Apache Spark SQL Data Source APIs with Join Push Down with Ioana De...Extending Apache Spark SQL Data Source APIs with Join Push Down with Ioana De...
Extending Apache Spark SQL Data Source APIs with Join Push Down with Ioana De...
 
Zend Framework 2, What's new, Confoo 2011
Zend Framework 2, What's new, Confoo 2011Zend Framework 2, What's new, Confoo 2011
Zend Framework 2, What's new, Confoo 2011
 
Eclipse e4
Eclipse e4Eclipse e4
Eclipse e4
 
FPGA DESIGN FLOW.pdf
FPGA DESIGN FLOW.pdfFPGA DESIGN FLOW.pdf
FPGA DESIGN FLOW.pdf
 
ApacheCon North America 2018: Creating Spark Data Sources
ApacheCon North America 2018: Creating Spark Data SourcesApacheCon North America 2018: Creating Spark Data Sources
ApacheCon North America 2018: Creating Spark Data Sources
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 
Data science lifecycle with Apache Zeppelin
Data science lifecycle with Apache ZeppelinData science lifecycle with Apache Zeppelin
Data science lifecycle with Apache Zeppelin
 
Getting up to speed with Kafka Connect: from the basics to the latest feature...
Getting up to speed with Kafka Connect: from the basics to the latest feature...Getting up to speed with Kafka Connect: from the basics to the latest feature...
Getting up to speed with Kafka Connect: from the basics to the latest feature...
 

Recently uploaded

WSO2CON 2024 - IoT Needs CIAM: The Importance of Centralized IAM in a Growing...
WSO2CON 2024 - IoT Needs CIAM: The Importance of Centralized IAM in a Growing...WSO2CON 2024 - IoT Needs CIAM: The Importance of Centralized IAM in a Growing...
WSO2CON 2024 - IoT Needs CIAM: The Importance of Centralized IAM in a Growing...WSO2
 
WSO2Con2024 - Low-Code Integration Tooling
WSO2Con2024 - Low-Code Integration ToolingWSO2Con2024 - Low-Code Integration Tooling
WSO2Con2024 - Low-Code Integration ToolingWSO2
 
WSO2Con2024 - Simplified Integration: Unveiling the Latest Features in WSO2 L...
WSO2Con2024 - Simplified Integration: Unveiling the Latest Features in WSO2 L...WSO2Con2024 - Simplified Integration: Unveiling the Latest Features in WSO2 L...
WSO2Con2024 - Simplified Integration: Unveiling the Latest Features in WSO2 L...WSO2
 
WSO2CON 2024 - How CSI Piemonte Is Apifying the Public Administration
WSO2CON 2024 - How CSI Piemonte Is Apifying the Public AdministrationWSO2CON 2024 - How CSI Piemonte Is Apifying the Public Administration
WSO2CON 2024 - How CSI Piemonte Is Apifying the Public AdministrationWSO2
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Bert Jan Schrijver
 
WSO2Con2024 - Facilitating Broadband Switching Services for UK Telecoms Provi...
WSO2Con2024 - Facilitating Broadband Switching Services for UK Telecoms Provi...WSO2Con2024 - Facilitating Broadband Switching Services for UK Telecoms Provi...
WSO2Con2024 - Facilitating Broadband Switching Services for UK Telecoms Provi...WSO2
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
WSO2Con2024 - Unleashing the Financial Potential of 13 Million People
WSO2Con2024 - Unleashing the Financial Potential of 13 Million PeopleWSO2Con2024 - Unleashing the Financial Potential of 13 Million People
WSO2Con2024 - Unleashing the Financial Potential of 13 Million PeopleWSO2
 
%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
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
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
 
WSO2Con2024 - Hello Choreo Presentation - Kanchana
WSO2Con2024 - Hello Choreo Presentation - KanchanaWSO2Con2024 - Hello Choreo Presentation - Kanchana
WSO2Con2024 - Hello Choreo Presentation - KanchanaWSO2
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 
WSO2CON 2024 - Building a Digital Government in Uganda
WSO2CON 2024 - Building a Digital Government in UgandaWSO2CON 2024 - Building a Digital Government in Uganda
WSO2CON 2024 - Building a Digital Government in UgandaWSO2
 
WSO2Con2024 - Organization Management: The Revolution in B2B CIAM
WSO2Con2024 - Organization Management: The Revolution in B2B CIAMWSO2Con2024 - Organization Management: The Revolution in B2B CIAM
WSO2Con2024 - Organization Management: The Revolution in B2B CIAMWSO2
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationJuha-Pekka Tolvanen
 
WSO2Con2024 - Software Delivery in Hybrid Environments
WSO2Con2024 - Software Delivery in Hybrid EnvironmentsWSO2Con2024 - Software Delivery in Hybrid Environments
WSO2Con2024 - Software Delivery in Hybrid EnvironmentsWSO2
 
WSO2CON2024 - Why Should You Consider Ballerina for Your Next Integration
WSO2CON2024 - Why Should You Consider Ballerina for Your Next IntegrationWSO2CON2024 - Why Should You Consider Ballerina for Your Next Integration
WSO2CON2024 - Why Should You Consider Ballerina for Your Next IntegrationWSO2
 

Recently uploaded (20)

WSO2CON 2024 - IoT Needs CIAM: The Importance of Centralized IAM in a Growing...
WSO2CON 2024 - IoT Needs CIAM: The Importance of Centralized IAM in a Growing...WSO2CON 2024 - IoT Needs CIAM: The Importance of Centralized IAM in a Growing...
WSO2CON 2024 - IoT Needs CIAM: The Importance of Centralized IAM in a Growing...
 
WSO2Con2024 - Low-Code Integration Tooling
WSO2Con2024 - Low-Code Integration ToolingWSO2Con2024 - Low-Code Integration Tooling
WSO2Con2024 - Low-Code Integration Tooling
 
WSO2Con2024 - Simplified Integration: Unveiling the Latest Features in WSO2 L...
WSO2Con2024 - Simplified Integration: Unveiling the Latest Features in WSO2 L...WSO2Con2024 - Simplified Integration: Unveiling the Latest Features in WSO2 L...
WSO2Con2024 - Simplified Integration: Unveiling the Latest Features in WSO2 L...
 
WSO2CON 2024 - How CSI Piemonte Is Apifying the Public Administration
WSO2CON 2024 - How CSI Piemonte Is Apifying the Public AdministrationWSO2CON 2024 - How CSI Piemonte Is Apifying the Public Administration
WSO2CON 2024 - How CSI Piemonte Is Apifying the Public Administration
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
WSO2Con2024 - Facilitating Broadband Switching Services for UK Telecoms Provi...
WSO2Con2024 - Facilitating Broadband Switching Services for UK Telecoms Provi...WSO2Con2024 - Facilitating Broadband Switching Services for UK Telecoms Provi...
WSO2Con2024 - Facilitating Broadband Switching Services for UK Telecoms Provi...
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
WSO2Con2024 - Unleashing the Financial Potential of 13 Million People
WSO2Con2024 - Unleashing the Financial Potential of 13 Million PeopleWSO2Con2024 - Unleashing the Financial Potential of 13 Million People
WSO2Con2024 - Unleashing the Financial Potential of 13 Million People
 
%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
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
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
 
WSO2Con2024 - Hello Choreo Presentation - Kanchana
WSO2Con2024 - Hello Choreo Presentation - KanchanaWSO2Con2024 - Hello Choreo Presentation - Kanchana
WSO2Con2024 - Hello Choreo Presentation - Kanchana
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
WSO2CON 2024 - Building a Digital Government in Uganda
WSO2CON 2024 - Building a Digital Government in UgandaWSO2CON 2024 - Building a Digital Government in Uganda
WSO2CON 2024 - Building a Digital Government in Uganda
 
WSO2Con2024 - Organization Management: The Revolution in B2B CIAM
WSO2Con2024 - Organization Management: The Revolution in B2B CIAMWSO2Con2024 - Organization Management: The Revolution in B2B CIAM
WSO2Con2024 - Organization Management: The Revolution in B2B CIAM
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
WSO2Con2024 - Software Delivery in Hybrid Environments
WSO2Con2024 - Software Delivery in Hybrid EnvironmentsWSO2Con2024 - Software Delivery in Hybrid Environments
WSO2Con2024 - Software Delivery in Hybrid Environments
 
WSO2CON2024 - Why Should You Consider Ballerina for Your Next Integration
WSO2CON2024 - Why Should You Consider Ballerina for Your Next IntegrationWSO2CON2024 - Why Should You Consider Ballerina for Your Next Integration
WSO2CON2024 - Why Should You Consider Ballerina for Your Next Integration
 

轉接器模式與表象模式

  • 1. Developer  Exchange  Group 深入淺出設計模式#5:   轉接器模式與表象模式   Prepare  by  Sean  Hsieh  
  • 3. Scene •  New  interface  doesn’t  work   –  New  vendor  designed  their  interfaces  differently  than  the   last  vendor.   Data  source:  Head  first  design  pa?ern
  • 4. How  to  use  old  design? •  An  adapter  designed   –  Designed  an  interfaces  to  adapter  the  old  interface.   Data  source:  Head  first  design  pa?ern
  • 5. Example  of  adapter  class Duck   quack()   Fly() Turkey   gobble()   Fly() Data  source:  Head  first  design  pa?ern
  • 6. Example  of  using  adapter  class Data  source:  Head  first  design  pa?ern
  • 7. DefiniLon  of  adapter  pa?ern •  Adapter  pa8ern     –  When  you  need  to  use  an  exisLng  class  and  interface  is  not  the  one  you  need   –  Usage:   •  converts  the  interface  of  a  class  into  another  interface  the  clients  except Data  source:  Head  first  design  pa?ern
  • 8. Kinds  of  adapter  pa?ern •  1.  Object  Adapter   Data  source:  Head  first  design  pa?ern
  • 9. Kinds  of  adapter  pa?ern  (cont.) •  2.  Class  Adapter   –  Class  adapter  use  mulLple  inheritance,  so  you  can’t  do  it  in   JAVA   Data  source:  Head  first  design  pa?ern
  • 10. Note •  1.  We  could  use  adapter  with  any  subclass  of   the  adaptee.   •  2.  Use  adapter  to  decouple  the  client  from  the   implemented  interface.   •  3.  You  can  rework  all  your  client-­‐side  calls  to   the  interface,  which  would  result  in  a  lot  of   invesLgaLve  work  and  code  changes.
  • 11. Facade  pa?ern   An  adapter  hold  two  or  more  adaptee
  • 12. scene •  Home  theater   –  We  have  to  do  many  thing  before  watching  movie Data  source:  Head  first  design  pa?ern
  • 13. How  to  simplify  these  procedure?   •  Facade  pa8ern   –  When  you  need  to  simplify  and  unify  a  large  interface  or  complex  set  of   interfaces   –  Usage:   •  Create  a  facade  class  with  a  simplified  method. Data  source:  Head  first  design  pa?ern
  • 14. Example  of  facade  pa?ern     Data  source:  Head  first  design  pa?ern
  • 15. Example  of  facade  pa?ern  (cont.)   Data  source:  Head  first  design  pa?ern
  • 16. Example  of  using  facade  pa?ern Data  source:  Head  first  design  pa?ern
  • 17. DefiniLon  of  facade  pa?ern •  Facade  pa8ern  provide  a  unified  interface  to  a   set  of  interfaces  in  a  subsystem.   Data  source:  Head  first  design  pa?ern
  • 18. Note •  1.  Facade  don’t  “encapsulate”  the  subsystem   classes;  they  merely  provide  a  simplified   interface  to  their  funcLonality.   •  2.  Facade  also  allows  you  decouple  your  client   implementaLon  from  any  one  subsystem.
  • 19. The  principle  of  Least  knowledge •  Talk  only  to  your  immediate  friends.   •  Also  called  Law  of  Demeter   •  Ex: Data  source:  Head  first  design  pa?ern
  • 20. More
  • 22. FuncLons  of  image  editor  
  • 23. Class  diagram  of  image  editor
  • 25. Class  diagram  of  Wallpaper  Product
  • 27. Class  diagram  of  Wallpaper  Product