gof-design-patterns
Skill2 starsChanged 11 months agoMITView on GitHub
Detects opportunities to apply GoF Design Patterns in Jakarta EE/MicroProfile. Use when reviewing code for structural improvements or implementing creational, structural, or behavioral patterns.
3 other projects use a version of this.
Adopted by
Most recently taken up by
- ice-lfernandes/claude-spring-architecttheir own version, first seen Nov 15, 2026
- nerviz-ai/nerviztheir own version, first seen Nov 15, 2026
- ryanthedev/code-foundationstheir own version, first seen Oct 8, 2026
Other versions3 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 3
- ryanthedev/code-foundations★ 389same name
- ice-lfernandes/claude-spring-architect★ 11same name
- nerviz-ai/nerviz★ 11same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository9 other files it gives its agents.
- cdd-design-pillarsSkill
- clean-code-principlesSkill
- ddd-da-massaSkill
- lombok-patternsSkill
- mapstruct-patternsSkill
- quarkus-panache-smellsSkill
- refactoring-catalogSkill
- rest-api-designSkill
- testing-patternsSkill
The file
We split this skill into the rules it gives an agent
4 rules. 0 are common, 4 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 3 edited versions we read keep these.
4
Distinctive
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 206
Simple cases: Don't add Factory for 2-3 types that rarely change
- Distinctive: line 207
YAGNI: Don't add patterns for "future flexibility"
- Distinctive: line 210
Team familiarity: Consider team's pattern knowledge
- Distinctive: line 216
All 23 GoF patterns with Jakarta EE implementations:
“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
GoF Design Patterns Refactoring Detection
Identify opportunities to apply Gang of Four (GoF) Design Patterns in Jakarta EE and MicroProfile applications.
Creational Patterns
Factory Method
Detect: if/switch with new based on type/condition
Refactor: CDI Instance<T> + @Named qualifiers
Cookbook: factory-method.md
Abstract Factory
Detect: Creating families of related objects with scattered logic
Refactor: CDI qualifiers for factory interface implementations
Cookbook: abstract-factory.md
Builder
Detect: Constructors with 4+ parameters, telescoping constructors, many setters in sequence
Refactor: Fluent builder with build() method, immutable objects
Cookbook: builder.md
Singleton
Detect: Manual getInstance() with double-checked locking
Refactor: @ApplicationScoped CDI bean
Cookbook: singleton.md
Prototype
Detect: Expensive object creation, need to copy/clone objects
Refactor: Cloneable interface + prototype registry
Cookbook: prototype.md
Structural Patterns
Adapter
Detect: Interface mismatch with external/legacy APIs
Refactor: CDI bean wrapping legacy system with target interface
Cookbook: adapter.md
Bridge
Detect: Abstraction and implementation should vary independently
Refactor: Separate hierarchy for implementors, inject via CDI
Cookbook: bridge.md
Composite
Detect: Tree/hierarchy structures (menus, org charts, file systems)
Refactor: Recursive interface, JPA @OneToMany self-reference
Cookbook: composite.md
Decorator
Detect: Inheritance explosion, cross-cutting concerns mixed in business logic
Refactor: CDI @Decorator + @Delegate, @Interceptor for AOP
Cookbook: decorator.md
Facade
Detect: Resource/controller calling multiple services directly
Refactor: @ApplicationScoped facade service orchestrating subsystems
Cookbook: facade.md
Flyweight
Detect: Many similar objects causing high memory usage
Refactor: Shared object cache, separate intrinsic/extrinsic state
Cookbook: flyweight.md
Proxy
Detect: Manual lazy loading, scattered access control checks
Refactor: CDI proxies (automatic), @RolesAllowed, MicroProfile REST Client
Cookbook: proxy.md
Behavioral Patterns
Chain of Responsibility
Detect: Sequential handler processing with hardcoded chain
Refactor: CDI Instance<T> + ordering, JAX-RS filters
Cookbook: chain-of-responsibility.md
Command
Detect: Operations needing undo/redo, queuing, or logging
Refactor: Command objects with execute()/undo() + executor
Cookbook: command.md
Interpreter
Detect: DSL/grammar parsing, configurable business rules
Refactor: Expression tree with interpret() method
Cookbook: interpreter.md
Iterator
Detect: Custom traversal needed, lazy loading from database
Refactor: Custom Iterator<T> for paginated queries
Cookbook: iterator.md
Mediator
Detect: Complex inter-object communication, many direct dependencies
Refactor: CDI Events (Event<T> + @Observes) or mediator service
Cookbook: mediator.md
Memento
Detect: Need undo/redo, state snapshots, version history
Refactor: Memento objects + caretaker for history
Cookbook: memento.md
Observer
Detect: Direct method calls to notify multiple dependents
Refactor: CDI Event<T> + @Observes / @ObservesAsync
Cookbook: observer.md
State
Detect: Complex conditionals based on object state (if status == X)
Refactor: State interface with per-state implementations
Cookbook: state.md
Strategy
Detect: switch/if-else selecting between algorithms
Refactor: CDI Instance<T> + strategy selection by qualifier/type
Cookbook: strategy.md
Template Method
Detect: Duplicate algorithm structure with varying steps
Refactor: Abstract class with final template + abstract hooks
Cookbook: template-method.md
Visitor
Detect: Operations across unrelated element types
Refactor: Visitor interface + accept(visitor) in elements
Cookbook: visitor.md
Quick Reference Table
| Pattern | Detection Signal | Jakarta EE/MP Integration |
| Factory Method | if/switch with new based on type | CDI Instance<T> + qualifiers |
| Abstract Factory | Creating families of related objects | CDI qualifiers for factory types |
| Builder | Constructors with 4+ parameters | Immutable objects + fluent API |
| Singleton | Manual getInstance() pattern | @ApplicationScoped |
| Prototype | Expensive object creation, need copies | Cloneable + prototype registry |
| Adapter | Interface mismatch with external APIs | CDI bean wrapping legacy |
| Bridge | Abstraction/implementation should vary | CDI for implementor injection |
| Composite | Tree/hierarchy structures | Recursive interface + JPA |
| Decorator | Inheritance for extending behavior | @Decorator, @Interceptor |
| Facade | Multiple service calls in controller | @ApplicationScoped facade |
| Flyweight | Many similar objects, high memory | Shared caches, object pools |
| Proxy | Manual lazy loading / access control | CDI proxies, @RolesAllowed |
| Chain of Responsibility | Sequential handler processing | CDI Instance<T> + ordering |
| Command | Operations needing undo/queue/log | Command objects + executor |
| Interpreter | DSL/grammar parsing, rule engines | Expression trees + parser |
| Iterator | Custom traversal, lazy DB loading | Iterator<T>, paginated queries |
| Mediator | Complex inter-object communication | CDI Events or mediator service |
| Memento | Undo/redo, state snapshots | Memento objects + caretaker |
| Observer | Direct calls to multiple dependents | CDI Event<T> + @Observes |
| State | Complex state-based conditionals | State interface + transitions |
| Strategy | switch/if-else selecting algorithm | CDI Instance<T> + iteration |
| Template Method | Duplicate algorithm with varying steps | Abstract class with hooks |
| Visitor | Operations across unrelated elements | Visitor interface + accept |
MicroProfile-Specific Patterns
| MP Feature | Pattern Applied | Example |
| Health Check | Factory + Strategy | @Liveness, @Readiness implementing HealthCheck |
| Fault Tolerance | Decorator/Proxy | @Retry, @Timeout, @Fallback annotations |
| Config | Strategy | @ConfigProperty to select behavior at runtime |
| REST Client | Proxy | Interface-based remote service invocation |
| Metrics | Decorator | @Counted, @Timed interceptors |
When NOT to Apply Patterns
- Simple cases: Don't add Factory for 2-3 types that rarely change
- YAGNI: Don't add patterns for "future flexibility"
- Performance-critical paths: Pattern overhead may matter
- Clear and readable code: Patterns shouldn't obscure intent
- Team familiarity: Consider team's pattern knowledge
Cookbook Index
All 23 GoF patterns with Jakarta EE implementations:
Creational (5): Factory Method · Abstract Factory · Builder · Singleton · Prototype
Structural (7): Adapter · Bridge · Composite · Decorator · Facade · Flyweight · Proxy
Behavioral (11): Chain of Responsibility · Command · Interpreter · Iterator · Mediator · Memento · Observer · State · Strategy · Template Method · Visitor
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

