Design Pattern - Adapter

Adapter 

Definition 

Adapter pattern is a software design pattern (also known as wrapper, an alternative naming shared with the decorator pattern) that allows the interface of an existing class to be used as another interface. It is often used to make existing classes work with others without modifying their source code.  

How Adapter works 

Let's look at simple example where we have a hair dryer that can fit to 110V and a cleaner that can fit to 220V. What if we only have 110V port and want to use cleaner? We can use an adapter that can convert 110V to 220V. 

Adapter with code



REFERENCE 

https://en.wikipedia.org/wiki/Adapter_pattern

Comments

Popular posts from this blog

Structures of JAVA

What is URI(URN, URL)

Spring Boot JPA - Pagination

Java Data Structures VS Python, C/C++ Data Structures

Spring Boot JPA - What is JPA, Entity, Repository

Design Pattern - Proxy