iluwatar / java-design-patterns

Design patterns implemented in Java
https://java-design-patterns.com
Other
88.46k stars 26.23k forks source link

Service Adapter pattern #1277

Open iluwatar opened 4 years ago

iluwatar commented 4 years ago

Description:

The Service Adapter design pattern aims to provide a bridge between different interfaces, enabling them to work together seamlessly. This pattern involves creating an adapter class that translates one interface for a class into an interface compatible with another class. The key elements of the pattern include:

  1. Client: The class that requires the target interface.
  2. Target Interface: The interface needed by the client.
  3. Service Interface: The existing interface provided by the service.
  4. Adapter: The class that implements the target interface and translates the requests from the client into calls to the service interface.

This pattern is particularly useful in scenarios where there is a need to integrate with third-party services or legacy systems with incompatible interfaces.

References:

Acceptance Criteria:

  1. An adapter class that implements the target interface and translates client requests to the service interface.
  2. Unit tests demonstrating the correct functionality of the adapter, ensuring it properly translates and forwards requests.
  3. Comprehensive documentation explaining the implemented design pattern, including class diagrams and usage examples.
lsnare commented 2 years ago

Hi - I would like to help out. Can I take a shot at this one?

iluwatar commented 2 years ago

Sure thing @lsnare. I'm looking forward to your PR!