Adapter Design Pattern in Java | Structural Design Pattern

Publicado em: 01 Janeiro 1970
no canal de: Coding Env
1,434
27

#design
#javadesignpattern
#codingenv
#java
#interviews


Adapter Design Pattern is a structural design pattern in Java that allows incompatible interfaces to work together.

In Java, an adapter is an object that acts as a bridge between two incompatible interfaces. It converts the interface of one class into another interface that clients expect. The adapter pattern allows two or more incompatible interfaces to work together by creating a middle layer between them.

In Java, the adapter pattern can be implemented using either class adapters or object adapters. Class adapters use inheritance to adapt the interface of one class to another, while object adapters use composition to adapt the interface of one object to another.

The adapter pattern is useful when you need to reuse existing code that is incompatible with the rest of your system. It allows you to adapt the existing code to fit your needs without having to modify it directly.

Pros and Cons of Adapter Design Pattern

Pros

1. Separation of Concern: We can separate the interface or data conversion code from the main business logic part of the code.
2. Independence of Code: We can implement and use the various adapters without breaking the existing client or main code.

Cons

1. We have to write a lot of code and it can decrease the efficiency. Sometimes it will be simpler to just change the code of a particular interface.


Nesta página do site você pode assistir ao vídeo on-line Adapter Design Pattern in Java | Structural Design Pattern duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário Coding Env 01 Janeiro 1970, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 1,434 vezes e gostou 27 espectadores. Boa visualização!