Class Adapter Pattern By Emon Dai Definition A pattern that allows - - PowerPoint PPT Presentation

class adapter pattern
SMART_READER_LITE
LIVE PREVIEW

Class Adapter Pattern By Emon Dai Definition A pattern that allows - - PowerPoint PPT Presentation

Class Adapter Pattern By Emon Dai Definition A pattern that allows two classes or interfaces to work together that were not designed to work with each other Also known as the Wrapper pattern Uses When there is an existing


slide-1
SLIDE 1

Class Adapter Pattern

By Emon Dai

slide-2
SLIDE 2

Definition

  • A pattern that allows two classes or interfaces to

work together that were not designed to work with each other

  • Also known as the “Wrapper” pattern
slide-3
SLIDE 3

Uses

  • When there is an existing class you want to use but

the current interface doesn’t meet your requirements or needs

  • When you want to create a new, reusable class that

works with another class that is not related

slide-4
SLIDE 4

Terminology

  • Target
  • The interface the client uses or wants to use
  • Client
  • Works with the objects that use Target interface (Main class)
  • Adaptee
  • The interface that you want to adapt. In Java, we subclass this class
  • Adapter
  • Adapts the interface of the Adaptee so that it works with the Target
  • interface. This inherits from the Adaptee in Java
slide-5
SLIDE 5

Diagram

slide-6
SLIDE 6

SavingsAccount To ICurrencyFormatter Adapter

slide-7
SLIDE 7

References

  • Design Patterns, Gamma, et. al., Addison Wesley,

1995, ISBN: 0201633612

  • http://www.avajava.com/tutorials/lessons/adapter-

pattern.html?page=1

  • https://msdn.microsoft.com/en-us/library/
  • rm-9780596527730-01-04.aspx