
Object Adapter Pattern in Software Design
Learn how the Object Adapter Pattern allows classes with incompatible interfaces to work together in software development. Explore its collaboration model, advantages, and ideal use cases for implementing this design pattern successfully.
Download Presentation

Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.
E N D
Presentation Transcript
Object Adapter Pattern Ziyi Feng ziyif@uchicago.edu
Problem Definition Target ExistingClass X Client Request() SpecificRequest() Client can only call classes that implemented Target interface ExistingClassdoesn t implement target interface We cannot change the interface that client expects nor we can change the interface of ExistingClass . Significant? Legacy System Third party library
Collaboration Clients call operations on the Adapter instance and Adapter delegates request to Adaptee. request delegate Clients Adapter Adaptee
Object Adapter Pattern Object Adapter let classes with incompatible interface work together An object adapter relies on object composition Target Adaptee Client SpecificRequest() Request() Adaptee Adapter Adaptee->SpecificRequest() Request()
Object Adapter Example Target Interface: OutletPlugable Adapter: PowerAdapter Adaptee: Outlet Client: CellPhone
Advantages Helps achieve flexibility Increases reusability lets a single Adapter work with many Adaptees
When we should use Adapter pattern: When client wants to interact with existing system using incompatible interface. When a new system wants to interact with legacy(old) system using new interface which is not compatible with interface of legacy system. When you want to use a 3rd party framework or library whose interface is incompatible with your system.