SlideShare una empresa de Scribd logo
1 de 13
Structural Design Patterns :
         Adapter




                   Manoj Kumar
                   Software Developer
                   manojksh9@gmail.com
Design Patterns

Design patterns are classified by two criteria:
Purpose and scope.

Creational: Concerns the process of object creation

Structural: Deals with the composition of classes or
objects

Behavioral: Characterizes the ways in which classes
or objects interact and distribute responsibility
Design Patterns




Purpose: Reflects what a pattern does
Scope: Specifies whether the pattern applies primarily to classes or to objec
Structural Design Patterns
                   Deals with the composition of classes or
                   objects
Structural patterns are concerned with how classes and
objects are composed to form larger structures.
Structural class patterns use inheritance to compose
interfaces or implementations.


Example:
Multiple inheritance mixes two or more classes into
one.


Class form of the Adapter pattern: In general, an
adapter makes one interface (the adaptee's) conform to
another, thereby providing a uniform abstraction of
different interfaces.
Structural Design Patterns :
Adapter
                    Deals with the composition of classes or
                    objects
Also Known As Wrapper

Convert the interface of a class into another interface
clients expect. Adapter lets classes work together that
couldn't otherwise because of incompatible interfaces.


What is an Adapter/Wrapper?

For Example: Shape + TextView = TextShape (Adapter)

Drawing editor: Draws lines/polygons, text; Pictures and
diagrams
Key abstraction: Graphical object (which has an editable shape and
can draw itself)
The interface for graphical objects: an abstract class “Shape”

The editor defines a subclass of Shape for each kind of graphical
object: a LineShape class for lines, a PolygonShape class for
polygons
Structural Design Patterns :
Adapter
                          Deals with the composition of classes or
                          objects
TextShape subclass: Display and edit, so considerably more difficult
to implement as complicated screen update and buffer management
are required
How to write this ‘TextShape’ subclass?

User interface toolkit (Already provide a sophisticated TextView class for
displaying and editing text)


A problem: Toolkit wasn't designed with Shape classes in mind. So we can't
use TextView and Shape objects interchangeably. How can existing and
unrelated classes like TextView work in an application that expects
classes with a different and incompatible interface?

Solution: A new class “TextShape” Adapts the TextView interface to
Shape's


                   An Adapter (Class version-by Inheriting
                           Object version-by composing)
Structural Design Patterns :
Adapter
              Deals with the composition of classes or
              objects




          Identify?? Class or Object
Structural Design Patterns :
Adapter
            Deals with the composition of classes or
            objects
Structural Design Patterns :
Adapter
                        Deals with the composition of classes or
                        objects
 Participants
 Target (Shape)
     defines the domain-specific interface that Client uses.
 Client (DrawingEditor)
     collaborates with objects conforming to the Target interface.
 Adaptee (TextView)
     defines an existing interface that needs adapting.
 Adapter (TextShape)
     adapts the interface of Adaptee to the Target interface.




 Collaborations
 Clients call operations on an Adapter instance. In turn, the adapter
 calls Adaptee operations that carry out the request.
Structural Design Patterns :
Adapter
                         Deals with the composition of classes or
                         objects
Consequences
Class and object adapters have different trade-offs.
A class adapter
adapts Adaptee to Target by committing to a concrete Adapter class.
As a consequence, a class adapter won't work when we want to adapt
a class and all its subclasses.
lets Adapter override some of Adaptee's behavior, since Adapter is a
subclass of Adaptee.
introduces only one object, and no additional pointer indirection is
needed to get to the adaptee.

An object adapter
lets a single Adapter work with many Adaptees—that is, the Adaptee
itself and all of its subclasses (if any). The Adapter can also add
functionality to all Adaptees at once.
makes it harder to override Adaptee behavior. It will require
subclassing Adaptee and making Adapter refer to the subclass rather
than the Adaptee itself.
Structural Design Patterns :
Adapter
                          Deals with the composition of classes or
                          objects
Applicability

You want to use an existing class, and its interface does not match
the one you need.

You want to create a reusable class that cooperates with unrelated
or unforeseen classes, that is, classes that don't necessarily have
compatible interfaces.

(object adapter only) You need to use several existing subclasses,
but it's impractical to adapt their interface by subclassing every one.
An object adapter can adapt the interface of its parent class.

Other issues to consider when using the Adapter pattern:
How much adapting does Adapter do?
Pluggable adapters (By building interface adaptation into a
class, you eliminate the assumption that other classes see the
same interface)
Using two-way adapters to provide transparency. (Two
Structural Design Patterns :
Adapter
                      Deals with the composition of classes or
                      objects
Project Example: Data Adapters (How??)
Thanks

Más contenido relacionado

La actualidad más candente

Hibernate Presentation
Hibernate  PresentationHibernate  Presentation
Hibernate Presentationguest11106b
 
Design Patterns - 01 Introduction and Decorator Pattern
Design Patterns - 01 Introduction and Decorator PatternDesign Patterns - 01 Introduction and Decorator Pattern
Design Patterns - 01 Introduction and Decorator Patterneprafulla
 
Bridge pattern for Dummies
Bridge pattern for DummiesBridge pattern for Dummies
Bridge pattern for DummiesTaekSoon Jang
 
Let us understand design pattern
Let us understand design patternLet us understand design pattern
Let us understand design patternMindfire Solutions
 
Dependency injection presentation
Dependency injection presentationDependency injection presentation
Dependency injection presentationAhasanul Kalam Akib
 
PATTERNS02 - Creational Design Patterns
PATTERNS02 - Creational Design PatternsPATTERNS02 - Creational Design Patterns
PATTERNS02 - Creational Design PatternsMichael Heron
 
20180518 QNAP Seminar - Introduction to React Native
20180518 QNAP Seminar - Introduction to React Native20180518 QNAP Seminar - Introduction to React Native
20180518 QNAP Seminar - Introduction to React NativeEric Deng
 
Jetpack Compose.pptx
Jetpack Compose.pptxJetpack Compose.pptx
Jetpack Compose.pptxGDSCVJTI
 
GoF Design patterns I: Introduction + Structural Patterns
GoF Design patterns I:   Introduction + Structural PatternsGoF Design patterns I:   Introduction + Structural Patterns
GoF Design patterns I: Introduction + Structural PatternsSameh Deabes
 
Java Database Connectivity (JDBC)
Java Database Connectivity (JDBC)Java Database Connectivity (JDBC)
Java Database Connectivity (JDBC)Pooja Talreja
 
Component diagram
Component diagramComponent diagram
Component diagramAbdul Manan
 
Spring Framework - AOP
Spring Framework - AOPSpring Framework - AOP
Spring Framework - AOPDzmitry Naskou
 

La actualidad más candente (20)

Design pattern-presentation
Design pattern-presentationDesign pattern-presentation
Design pattern-presentation
 
Hibernate Presentation
Hibernate  PresentationHibernate  Presentation
Hibernate Presentation
 
Design Patterns - 01 Introduction and Decorator Pattern
Design Patterns - 01 Introduction and Decorator PatternDesign Patterns - 01 Introduction and Decorator Pattern
Design Patterns - 01 Introduction and Decorator Pattern
 
Bridge pattern for Dummies
Bridge pattern for DummiesBridge pattern for Dummies
Bridge pattern for Dummies
 
Let us understand design pattern
Let us understand design patternLet us understand design pattern
Let us understand design pattern
 
Dependency injection presentation
Dependency injection presentationDependency injection presentation
Dependency injection presentation
 
Spring Core
Spring CoreSpring Core
Spring Core
 
Flyweight Pattern
Flyweight PatternFlyweight Pattern
Flyweight Pattern
 
PATTERNS02 - Creational Design Patterns
PATTERNS02 - Creational Design PatternsPATTERNS02 - Creational Design Patterns
PATTERNS02 - Creational Design Patterns
 
Java Spring Framework
Java Spring FrameworkJava Spring Framework
Java Spring Framework
 
Factory Method Pattern
Factory Method PatternFactory Method Pattern
Factory Method Pattern
 
20180518 QNAP Seminar - Introduction to React Native
20180518 QNAP Seminar - Introduction to React Native20180518 QNAP Seminar - Introduction to React Native
20180518 QNAP Seminar - Introduction to React Native
 
Hibernate tutorial
Hibernate tutorialHibernate tutorial
Hibernate tutorial
 
Jetpack Compose.pptx
Jetpack Compose.pptxJetpack Compose.pptx
Jetpack Compose.pptx
 
Adapter Design Pattern
Adapter Design PatternAdapter Design Pattern
Adapter Design Pattern
 
GoF Design patterns I: Introduction + Structural Patterns
GoF Design patterns I:   Introduction + Structural PatternsGoF Design patterns I:   Introduction + Structural Patterns
GoF Design patterns I: Introduction + Structural Patterns
 
Software Design Patterns
Software Design PatternsSoftware Design Patterns
Software Design Patterns
 
Java Database Connectivity (JDBC)
Java Database Connectivity (JDBC)Java Database Connectivity (JDBC)
Java Database Connectivity (JDBC)
 
Component diagram
Component diagramComponent diagram
Component diagram
 
Spring Framework - AOP
Spring Framework - AOPSpring Framework - AOP
Spring Framework - AOP
 

Destacado

The Decorator Pattern
The Decorator PatternThe Decorator Pattern
The Decorator PatternAkshat Vig
 
Decorator design pattern (A Gift Wrapper)
Decorator design pattern (A Gift Wrapper)Decorator design pattern (A Gift Wrapper)
Decorator design pattern (A Gift Wrapper)Sameer Rathoud
 
Structural patterns
Structural patternsStructural patterns
Structural patternsHimanshu
 

Destacado (6)

Composite Design Pattern
Composite Design PatternComposite Design Pattern
Composite Design Pattern
 
The Decorator Pattern
The Decorator PatternThe Decorator Pattern
The Decorator Pattern
 
Composite Pattern
Composite PatternComposite Pattern
Composite Pattern
 
Composite pattern
Composite patternComposite pattern
Composite pattern
 
Decorator design pattern (A Gift Wrapper)
Decorator design pattern (A Gift Wrapper)Decorator design pattern (A Gift Wrapper)
Decorator design pattern (A Gift Wrapper)
 
Structural patterns
Structural patternsStructural patterns
Structural patterns
 

Similar a Structural Design pattern - Adapter

M04 Design Patterns
M04 Design PatternsM04 Design Patterns
M04 Design PatternsDang Tuan
 
Patterns (contd)Software Development ProcessDesign patte.docx
Patterns (contd)Software Development ProcessDesign patte.docxPatterns (contd)Software Development ProcessDesign patte.docx
Patterns (contd)Software Development ProcessDesign patte.docxdanhaley45372
 
Architecture and design
Architecture and designArchitecture and design
Architecture and designhimanshu_airon
 
UML-Advanced Software Engineering
UML-Advanced Software EngineeringUML-Advanced Software Engineering
UML-Advanced Software EngineeringAmit Singh
 
Cocoa and MVC in ios, iOS Training Ahmedbad , iOS classes Ahmedabad
Cocoa and MVC in ios, iOS Training Ahmedbad , iOS classes Ahmedabad Cocoa and MVC in ios, iOS Training Ahmedbad , iOS classes Ahmedabad
Cocoa and MVC in ios, iOS Training Ahmedbad , iOS classes Ahmedabad NicheTech Com. Solutions Pvt. Ltd.
 
Design Patterns For 70% Of Programmers In The World
Design Patterns For 70% Of Programmers In The WorldDesign Patterns For 70% Of Programmers In The World
Design Patterns For 70% Of Programmers In The WorldSaurabh Moody
 
Cs 1023 lec 8 design pattern (week 2)
Cs 1023 lec 8 design pattern (week 2)Cs 1023 lec 8 design pattern (week 2)
Cs 1023 lec 8 design pattern (week 2)stanbridge
 
Class and object_diagram
Class  and object_diagramClass  and object_diagram
Class and object_diagramSadhana28
 
Prophecy Of Design Patterns
Prophecy Of Design PatternsProphecy Of Design Patterns
Prophecy Of Design Patternspradeepkothiyal
 
My design patterns
My design patternsMy design patterns
My design patternszenwalker
 
Design Pattern Notes: Nagpur University
Design Pattern Notes: Nagpur UniversityDesign Pattern Notes: Nagpur University
Design Pattern Notes: Nagpur UniversityShubham Narkhede
 
Final sdp ppt
Final sdp pptFinal sdp ppt
Final sdp pptnancy_17
 
Basic design pattern interview questions
Basic design pattern interview questionsBasic design pattern interview questions
Basic design pattern interview questionsjinaldesailive
 
Advanced Structural Modeling
Advanced Structural ModelingAdvanced Structural Modeling
Advanced Structural ModelingAMITJain879
 

Similar a Structural Design pattern - Adapter (20)

Sda 9
Sda   9Sda   9
Sda 9
 
M04 Design Patterns
M04 Design PatternsM04 Design Patterns
M04 Design Patterns
 
Sda 7
Sda   7Sda   7
Sda 7
 
Patterns (contd)Software Development ProcessDesign patte.docx
Patterns (contd)Software Development ProcessDesign patte.docxPatterns (contd)Software Development ProcessDesign patte.docx
Patterns (contd)Software Development ProcessDesign patte.docx
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Architecture and design
Architecture and designArchitecture and design
Architecture and design
 
UML-Advanced Software Engineering
UML-Advanced Software EngineeringUML-Advanced Software Engineering
UML-Advanced Software Engineering
 
Cocoa and MVC in ios, iOS Training Ahmedbad , iOS classes Ahmedabad
Cocoa and MVC in ios, iOS Training Ahmedbad , iOS classes Ahmedabad Cocoa and MVC in ios, iOS Training Ahmedbad , iOS classes Ahmedabad
Cocoa and MVC in ios, iOS Training Ahmedbad , iOS classes Ahmedabad
 
Design Patterns For 70% Of Programmers In The World
Design Patterns For 70% Of Programmers In The WorldDesign Patterns For 70% Of Programmers In The World
Design Patterns For 70% Of Programmers In The World
 
Cs 1023 lec 8 design pattern (week 2)
Cs 1023 lec 8 design pattern (week 2)Cs 1023 lec 8 design pattern (week 2)
Cs 1023 lec 8 design pattern (week 2)
 
Class and object_diagram
Class  and object_diagramClass  and object_diagram
Class and object_diagram
 
Prophecy Of Design Patterns
Prophecy Of Design PatternsProphecy Of Design Patterns
Prophecy Of Design Patterns
 
Design patterns
Design patternsDesign patterns
Design patterns
 
My design patterns
My design patternsMy design patterns
My design patterns
 
Design Pattern Notes: Nagpur University
Design Pattern Notes: Nagpur UniversityDesign Pattern Notes: Nagpur University
Design Pattern Notes: Nagpur University
 
Final sdp ppt
Final sdp pptFinal sdp ppt
Final sdp ppt
 
Facade pattern
Facade patternFacade pattern
Facade pattern
 
Basic design pattern interview questions
Basic design pattern interview questionsBasic design pattern interview questions
Basic design pattern interview questions
 
Advanced Structural Modeling
Advanced Structural ModelingAdvanced Structural Modeling
Advanced Structural Modeling
 
Advance oops concepts
Advance oops conceptsAdvance oops concepts
Advance oops concepts
 

Más de Manoj Kumar

Cloud Computing – Jump start cloud development with Microsoft Azure (Part-2)
Cloud Computing – Jump start cloud development with Microsoft Azure (Part-2)Cloud Computing – Jump start cloud development with Microsoft Azure (Part-2)
Cloud Computing – Jump start cloud development with Microsoft Azure (Part-2)Manoj Kumar
 
Cloud Computing – Opportunities, Definitions, Options, and Risks (Part-1)
Cloud Computing – Opportunities, Definitions, Options, and Risks (Part-1)Cloud Computing – Opportunities, Definitions, Options, and Risks (Part-1)
Cloud Computing – Opportunities, Definitions, Options, and Risks (Part-1)Manoj Kumar
 
BizTalk Orchestration Fundamentals
BizTalk Orchestration FundamentalsBizTalk Orchestration Fundamentals
BizTalk Orchestration FundamentalsManoj Kumar
 
BizTalk Messaging Fundamentals
BizTalk  Messaging FundamentalsBizTalk  Messaging Fundamentals
BizTalk Messaging FundamentalsManoj Kumar
 
BizTalk Fundamentals
BizTalk  FundamentalsBizTalk  Fundamentals
BizTalk FundamentalsManoj Kumar
 
Introduction to ASP.Net Mvc3 with Razor
Introduction to ASP.Net Mvc3 with RazorIntroduction to ASP.Net Mvc3 with Razor
Introduction to ASP.Net Mvc3 with RazorManoj Kumar
 
Server vs Client in real life and in programming world
Server vs Client in real life and in programming worldServer vs Client in real life and in programming world
Server vs Client in real life and in programming worldManoj Kumar
 
Html5 Introduction
Html5 IntroductionHtml5 Introduction
Html5 IntroductionManoj Kumar
 
N-Tier Application Architecture
N-Tier Application ArchitectureN-Tier Application Architecture
N-Tier Application ArchitectureManoj Kumar
 

Más de Manoj Kumar (9)

Cloud Computing – Jump start cloud development with Microsoft Azure (Part-2)
Cloud Computing – Jump start cloud development with Microsoft Azure (Part-2)Cloud Computing – Jump start cloud development with Microsoft Azure (Part-2)
Cloud Computing – Jump start cloud development with Microsoft Azure (Part-2)
 
Cloud Computing – Opportunities, Definitions, Options, and Risks (Part-1)
Cloud Computing – Opportunities, Definitions, Options, and Risks (Part-1)Cloud Computing – Opportunities, Definitions, Options, and Risks (Part-1)
Cloud Computing – Opportunities, Definitions, Options, and Risks (Part-1)
 
BizTalk Orchestration Fundamentals
BizTalk Orchestration FundamentalsBizTalk Orchestration Fundamentals
BizTalk Orchestration Fundamentals
 
BizTalk Messaging Fundamentals
BizTalk  Messaging FundamentalsBizTalk  Messaging Fundamentals
BizTalk Messaging Fundamentals
 
BizTalk Fundamentals
BizTalk  FundamentalsBizTalk  Fundamentals
BizTalk Fundamentals
 
Introduction to ASP.Net Mvc3 with Razor
Introduction to ASP.Net Mvc3 with RazorIntroduction to ASP.Net Mvc3 with Razor
Introduction to ASP.Net Mvc3 with Razor
 
Server vs Client in real life and in programming world
Server vs Client in real life and in programming worldServer vs Client in real life and in programming world
Server vs Client in real life and in programming world
 
Html5 Introduction
Html5 IntroductionHtml5 Introduction
Html5 Introduction
 
N-Tier Application Architecture
N-Tier Application ArchitectureN-Tier Application Architecture
N-Tier Application Architecture
 

Último

Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 

Último (20)

Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 

Structural Design pattern - Adapter

  • 1. Structural Design Patterns : Adapter Manoj Kumar Software Developer manojksh9@gmail.com
  • 2. Design Patterns Design patterns are classified by two criteria: Purpose and scope. Creational: Concerns the process of object creation Structural: Deals with the composition of classes or objects Behavioral: Characterizes the ways in which classes or objects interact and distribute responsibility
  • 3. Design Patterns Purpose: Reflects what a pattern does Scope: Specifies whether the pattern applies primarily to classes or to objec
  • 4. Structural Design Patterns Deals with the composition of classes or objects Structural patterns are concerned with how classes and objects are composed to form larger structures. Structural class patterns use inheritance to compose interfaces or implementations. Example: Multiple inheritance mixes two or more classes into one. Class form of the Adapter pattern: In general, an adapter makes one interface (the adaptee's) conform to another, thereby providing a uniform abstraction of different interfaces.
  • 5. Structural Design Patterns : Adapter Deals with the composition of classes or objects Also Known As Wrapper Convert the interface of a class into another interface clients expect. Adapter lets classes work together that couldn't otherwise because of incompatible interfaces. What is an Adapter/Wrapper? For Example: Shape + TextView = TextShape (Adapter) Drawing editor: Draws lines/polygons, text; Pictures and diagrams Key abstraction: Graphical object (which has an editable shape and can draw itself) The interface for graphical objects: an abstract class “Shape” The editor defines a subclass of Shape for each kind of graphical object: a LineShape class for lines, a PolygonShape class for polygons
  • 6. Structural Design Patterns : Adapter Deals with the composition of classes or objects TextShape subclass: Display and edit, so considerably more difficult to implement as complicated screen update and buffer management are required How to write this ‘TextShape’ subclass? User interface toolkit (Already provide a sophisticated TextView class for displaying and editing text) A problem: Toolkit wasn't designed with Shape classes in mind. So we can't use TextView and Shape objects interchangeably. How can existing and unrelated classes like TextView work in an application that expects classes with a different and incompatible interface? Solution: A new class “TextShape” Adapts the TextView interface to Shape's An Adapter (Class version-by Inheriting Object version-by composing)
  • 7. Structural Design Patterns : Adapter Deals with the composition of classes or objects Identify?? Class or Object
  • 8. Structural Design Patterns : Adapter Deals with the composition of classes or objects
  • 9. Structural Design Patterns : Adapter Deals with the composition of classes or objects Participants Target (Shape) defines the domain-specific interface that Client uses. Client (DrawingEditor) collaborates with objects conforming to the Target interface. Adaptee (TextView) defines an existing interface that needs adapting. Adapter (TextShape) adapts the interface of Adaptee to the Target interface. Collaborations Clients call operations on an Adapter instance. In turn, the adapter calls Adaptee operations that carry out the request.
  • 10. Structural Design Patterns : Adapter Deals with the composition of classes or objects Consequences Class and object adapters have different trade-offs. A class adapter adapts Adaptee to Target by committing to a concrete Adapter class. As a consequence, a class adapter won't work when we want to adapt a class and all its subclasses. lets Adapter override some of Adaptee's behavior, since Adapter is a subclass of Adaptee. introduces only one object, and no additional pointer indirection is needed to get to the adaptee. An object adapter lets a single Adapter work with many Adaptees—that is, the Adaptee itself and all of its subclasses (if any). The Adapter can also add functionality to all Adaptees at once. makes it harder to override Adaptee behavior. It will require subclassing Adaptee and making Adapter refer to the subclass rather than the Adaptee itself.
  • 11. Structural Design Patterns : Adapter Deals with the composition of classes or objects Applicability You want to use an existing class, and its interface does not match the one you need. You want to create a reusable class that cooperates with unrelated or unforeseen classes, that is, classes that don't necessarily have compatible interfaces. (object adapter only) You need to use several existing subclasses, but it's impractical to adapt their interface by subclassing every one. An object adapter can adapt the interface of its parent class. Other issues to consider when using the Adapter pattern: How much adapting does Adapter do? Pluggable adapters (By building interface adaptation into a class, you eliminate the assumption that other classes see the same interface) Using two-way adapters to provide transparency. (Two
  • 12. Structural Design Patterns : Adapter Deals with the composition of classes or objects Project Example: Data Adapters (How??)

Notas del editor

  1. A class adapter accomplishes this by inheriting privately from an adaptee class. The adapter then expresses its interface in terms of the adaptee's.