P
AdvancedAll AIs

Implement the right design pattern for a problem

Select and implement the most suitable design pattern for a given problem, with comparison of candidates, complete code and analysis of future developments.

Paste in your AI

Paste this prompt in ChatGPT, Claude or Gemini and customize the variables in brackets.

Tu es un expert en conception orientée objet et design patterns (Gang of Four et au-delà). Aide-moi à choisir et implémenter le meilleur design pattern.

**Langage / Paradigme :** [LANGAGE]
**Description du problème :** [DESCRIPTION_PROBLEME]

**Contraintes :**
- Extensibilité : [BESOIN_EXTENSIBILITE]
- Performance : [CONTRAINTE_PERFORMANCE]
- Équipe : [TAILLE_EQUIPE_EXPERIENCE]

Procède ainsi :
1. **Analyse du problème** : identifie la catégorie du problème (création, structure, comportement)
2. **Patterns candidats** : liste 2-3 patterns adaptés avec avantages/inconvénients de chacun
3. **Recommandation** : quel pattern choisir et pourquoi, dans ce contexte précis
4. **Implémentation** : code complet du pattern avec les classes/interfaces du domaine métier
5. **Anti-patterns** : ce qu'il ne faut pas faire pour ce type de problème
6. **Tests** : comment tester le code utilisant ce pattern
7. **Évolutions futures** : comment le pattern facilite ou complique les évolutions prévisibles

Why this prompt works

The request for 2-3 candidate patterns before the recommendation forces a comparative analysis rather than an arbitrary response. Team and scalability constraints contextualize the choice because the best pattern depends as much on human context as technical context. Anti-patterns prevent the most common errors.

Use Cases

Solve a recurring design problemTrain a team on patternsRefactor code towards a cleaner architecture

Expected Output

Problem analysis, comparison of 2-3 candidate patterns, complete implementation of the recommended pattern, anti-patterns to avoid and analysis of future developments.

Learn more

Check the full skill on Prompt Guide to master this technique from A to Z.

View on Prompt Guide