sarcar-java-design-patterns

Provides reference guidance on all 23 GoF design patterns with Java examples and comparisons.

Updated Jul 28, 2026
One-click install
npx skills add https://github.com/zademy/book-to-skill-zademy --skill sarcar-java-design-patterns-zademy
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: sarcar-java-design-patterns
Source: https://github.com/zademy/book-to-skill-zademy/tree/main/.agents/skills/sarcar-java-design-patterns
Command: npx skills add https://github.com/zademy/book-to-skill-zademy --skill sarcar-java-design-patterns-zademy

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Choosing and correctly applying design patterns in Java is hard because many patterns share identical UML structures while differing in intent. This Skill provides a structured knowledge base from Vaskaran Sarcar's "Java Design Patterns, 2nd Edition" covering all 23 GoF patterns plus Simple Factory, Null Object, and MVC, so you can pick the right pattern, understand trade-offs, and avoid antipatterns. ## Core Features & Use Cases - Pattern Reference by Chapter: Load any of 29 chapter files covering intent, participants, implementation variants, and Q&A-driven trade-off analysis for each pattern. - Confused-Pair Comparisons: Get intent-based distinctions for commonly mixed-up pairs like Proxy vs Decorator, State vs Strategy, and Adapter vs Bridge via the FAQ chapter. - Decision Support: Use the cheatsheet's decision tree, threshold rules (e.g., 4+ constructor params suggests Builder), Java built-in examples, and antipattern red flags. - Use Case: When refactoring a class with growing if-else chains on object state, ask about the State pattern to get its structure, transition ownership guidance, and a comparison with Strategy before rewriting the code. ## Quick Start Ask the agent to explain the difference between the Proxy and Decorator patterns with a Java example using this design patterns skill.

Frequently Asked Questions about sarcar-java-design-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I choose between similar design patterns in Java?▼

Compare intent rather than UML structure, since pairs like State and Strategy look identical structurally. Ask who triggers the change: clients set strategies explicitly, while objects transition between states internally. The FAQ chapter covers the most common confused pairs.

What is the difference between Proxy, Decorator, and Adapter patterns?▼

Proxy controls access while keeping the same interface, Decorator adds behavior dynamically with the same interface, and Adapter converts an incompatible interface. The key question is whether the pattern restricts, enhances, or translates.

When should I use the Builder pattern instead of constructors?▼

Use Builder when a constructor has four or more parameters, when immutability is desired, or when construction order matters. For three or fewer parameters, telescoping constructors or JavaBeans setters are sufficient.

Does this skill cover modern Java features like records and sealed classes?▼

No, the content is based on Java 8-era examples from the book, and records, sealed classes, virtual threads, and pattern matching postdate it. Combine the pattern guidance with project-specific knowledge for modern Java idioms.

What are common design pattern antipatterns to avoid?▼

Key antipatterns include God Class from misused Mediator, Over Use of Patterns, Zero Means Null sentinel values, Golden Hammer, and Copy-Paste Programming. The antipatterns chapter provides prevention guidance and refactoring paths for each.