-
Notifications
You must be signed in to change notification settings - Fork 0
Adapter Design Pattern
Devrath edited this page Mar 5, 2024
·
2 revisions
Contents |
---|
Gangs of Four(GOF) - Definition |
General reference scenario |
Examples in Android |
Programming Example |
Provides an interface between two unrelated entities so that they can work together.
- Consider there is a new device we want to connect to our
computer
viaBluetooth
-
Computer
has aBluetooth
device which connects to external devices via `Bluetooth - The software of the new device that has to be connected to the computer is different.
- Similarly the software of the computer Bluetooth is different.
- Our goal is to link them but both are different and can't be linked directly.
- We use the adapter pattern to solve this problem.
- One good example in Android programming is the usage of an adapter in populating the list.
- There will be a data source in the
activity/fragment
and we need to display it in a certain way in the list. - The adapter will form a mediation between the data source and how it should be displayed.
.