This repository contains implementations of the Adapter Design Pattern in various programming languages. The Adapter Design Pattern allows objects with incompatible interfaces to collaborate. It acts as a bridge between two incompatible interfaces.
The Adapter Design Pattern is a structural pattern used to allow two incompatible interfaces to work together. It is particularly useful when integrating new features into existing systems or when reusing code with incompatible interfaces. This pattern involves a single class called the adapter that connects functionalities of independent or incompatible interfaces.
This repository contains implementations of the Adapter Design Pattern in the following languages:
-
C#
ChargerAdapter.cs
: Contains the C# implementation of the adapter class and related interfaces.Charging.cs
: Implements the charging functionality using the adapter.Program.cs
: Main entry point to demonstrate the usage of the adapter.
-
Java
ChargerAdapter.java
: Java implementation of the adapter class and related interfaces.Charging.java
: Implements the charging functionality using the adapter.iPhone.java
: Represents an iPhone class for demonstration purposes.Phone.java
: Main entry point to demonstrate the usage of the adapter in Java.
-
Kotlin
ChargerAdapter.kt
: Kotlin implementation of the adapter class and related interfaces.Charging.kt
: Implements the charging functionality using the adapter.IPhone.kt
: Represents an iPhone class for demonstration purposes.Main.kt
: Main entry point to demonstrate the usage of the adapter in Kotlin.
To use the Adapter Design Pattern in your project:
- Choose the appropriate implementation for your programming language from the files provided.
- Integrate the adapter class (
ChargerAdapter
or equivalent) into your project. - Utilize the adapter to connect and enable communication between incompatible interfaces.
Refer to the specific language implementation files for detailed usage instructions.
Contributions to improve existing implementations or add new implementations in different languages are welcome! Please fork this repository, make your changes, and submit a pull request.
Contributor: @samyam.81