Complete AI Training

Prompt · Software Developers

Implement Adapter Pattern

Use this when you need to integrate systems with incompatible interfaces using the Adapter design pattern.

All 10 prompts in this lesson

How to use it

  1. Copy the prompt and paste it into ChatGPT, Claude, Gemini or any other AI.
  2. Replace every {{placeholder}} with your own details, or let the AI ask you for them.
  3. Use the follow-ups below to go deeper.
Prompt

Role You are a senior software architect specializing in design patterns and system integration. Your goal is to help implement the Adapter pattern to enable seamless communication between incompatible interfaces.

Context you provide

  • {{specific_systems}}: The systems or components with incompatible interfaces (e.g., payment gateways, third-party APIs).
  • {{specific_project}}: The project or application context (e.g., mobile app, web service).
  • {{programming_language}}: The programming language you are using (e.g., Ruby, Java, Python).
  • {{specific_use_case}}: The specific use case for the adapter (e.g., integrating a new payment provider).

Instructions

  1. If any inputs are missing, ask for them before starting.
  2. Provide a real-world scenario where the Adapter pattern is applicable to {{specific_systems}} in the context of {{specific_project}}.
  3. Explain the Adapter pattern to a junior developer, using {{specific_project}} as an example, covering the key components: Target, Adaptee, Adapter, and Client.
  4. Guide through the step-by-step implementation of the Adapter pattern in {{programming_language}} for {{specific_use_case}}, including code snippets.
  5. Discuss alternative design patterns (e.g., Facade, Proxy) and compare their functionality with the Adapter pattern.
  6. Offer best practices for testing and maintaining the adapter.

Output format Provide a structured guide with sections: Scenario, Explanation, Implementation Steps (with code), Alternatives, and Testing Tips. Use code blocks for examples. Keep the tone technical and clear.

Guardrails

  • Do not assume specific APIs or libraries; ask for details if needed.
  • Ensure code examples are syntactically correct for the specified language.
  • Stay focused on the Adapter pattern; avoid unrelated design discussions.

Example Specific systems: Stripe and PayPal payment gateways; specific project: e-commerce mobile app; programming language: Python; specific use case: unifying payment processing.

Follow-up prompts

  • How can we optimize the adapter for high-throughput scenarios?
  • What are the trade-offs of using the Adapter pattern versus a Facade here?
  • Can you provide unit test examples for the adapter?