Prompt lesson · 10 prompts
Design Pattern Implementation prompts for Software Developers
10 ready-to-use prompts from our AI for Software Developers course. Copy one, fill in the {{placeholders}}, and paste it into ChatGPT, Claude, Gemini or any other AI.
Implement Adapter Pattern
Use this when you need to integrate systems with incompatible interfaces using the Adapter design pattern.
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
- If any inputs are missing, ask for them before starting.
- Provide a real-world scenario where the Adapter pattern is applicable to {{specific_systems}} in the context of {{specific_project}}.
- Explain the Adapter pattern to a junior developer, using {{specific_project}} as an example, covering the key components: Target, Adaptee, Adapter, and Client.
- Guide through the step-by-step implementation of the Adapter pattern in {{programming_language}} for {{specific_use_case}}, including code snippets.
- Discuss alternative design patterns (e.g., Facade, Proxy) and compare their functionality with the Adapter pattern.
- 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.
Open this prompt Coding · Intermediate
Implement Command Pattern
Use this when you need to encapsulate requests as objects to enable undo/redo, queuing, or logging in your application.
Role You are a senior software architect with deep expertise in behavioral design patterns. Your goal is to help implement the Command pattern to improve modularity and enable advanced features like undo/redo.
Context you provide
- {{specific_application}}: The application or tool where the pattern will be used (e.g., task management tool, text editor).
- {{specific_project}}: The project context (e.g., a desktop app, web app).
- {{specific_context}}: The specific context or feature (e.g., GUI actions, macro recording).
- {{programming_language}}: The programming language you are using.
Instructions
- If any inputs are missing, ask for them before starting.
- Explain how to structure commands using the Command pattern in {{specific_application}}, detailing the key components: Command, ConcreteCommand, Receiver, Invoker, and Client.
- Provide a step-by-step guide to implement undo/redo functionality using the Command pattern in {{specific_project}}, including code examples.
- Discuss the advantages of using the Command pattern in {{specific_context}}, with code snippets to illustrate.
- Offer guidance on designing and implementing commands to enhance modularity in your software project.
- Compare the Command pattern with other behavioral patterns (e.g., Strategy, Observer) in terms of flexibility.
Output format Provide a structured guide with sections: Overview, Key Components, Implementation Steps (with code), Advantages, and Pattern Comparison. Use code blocks for examples. Keep the tone technical and instructive.
Guardrails
- Do not assume the programming language or framework; ask if not provided.
- Ensure code examples are complete and runnable in the specified language.
- Stay within the scope of the Command pattern; avoid unrelated design discussions.
Example Specific application: text editor; specific project: a cross-platform editor; specific context: GUI actions; programming language: Java.
Open this prompt Coding · Intermediate
Implement Composite Pattern
Use this when you need to treat individual objects and compositions uniformly, such as in hierarchical structures.
Open this prompt Coding · Intermediate
Implement Decorator Pattern
Use this when you need to dynamically add responsibilities to objects without modifying their code.
Open this prompt Coding · Intermediate
Implement Factory Pattern
Use this when you need to design or implement the Factory pattern to create objects without specifying their concrete classes.
Open this prompt Coding · Intermediate
Implement Iterator Pattern
Use this when you need to implement the Iterator pattern to traverse collections without exposing their internal structure.
Open this prompt Coding · Beginner
Implement Observer Pattern
Use this when you need to implement the Observer pattern to enable one-to-many dependency and automatic updates between objects.
Open this prompt Coding · Intermediate
Implement Proxy Pattern
Use this when you need to implement the Proxy pattern to control access to resources, add security, or optimize performance.
Open this prompt Coding · Intermediate
Implement Strategy Pattern
Use this when you need to implement the Strategy pattern to select algorithms at runtime and make your code more flexible.
Open this prompt Coding · Intermediate
Implement Template Method Pattern
Use this when you need to design or implement the Template Method pattern in a specific context or language.
Open this prompt Coding · Intermediate