Skip to content
Back to skills

Gof Design Patterns

ASecurity

Knowledge base from \"Design Patterns: Elements of Reusable Object-Oriented Software\" by Gamma, Helm, Johnson & Vlissides (GoF). Use when applying GoF patterns (creational, structural, behavioral), choosing between patterns, studying the book, or referencing its concepts.

  • 3 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 3, 2026
ai-agentspythongoc++refactoring

Works with

  • cli

Security analysis

A100/100

Pro scans all 10 files and shows the line behind each finding

Scanned December 3, 2026

npx -y skills add Kaiohz/ai-driven --skill gof-design-patterns --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Gof Design Patterns?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Gof Design Patterns
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/kaiohz-gof-design-patterns/badge)](https://www.skillsdirectory.com/skills/kaiohz-gof-design-patterns)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: gof-design-patterns
description: "Knowledge base from \"Design Patterns: Elements of Reusable Object-Oriented Software\" by Gamma, Helm, Johnson & Vlissides (GoF). Use when applying GoF patterns (creational, structural, behavioral), choosing between patterns, studying the book, or referencing its concepts."
---

<!-- argument-hint: [topic, pattern name, or chapter number] -->

# Design Patterns: Elements of Reusable Object-Oriented Software
**Author**: Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides ("Gang of Four") | **Pages**: ~417 | **Chapters**: 6 (23 patterns) | **Generated**: 2026-09-18

## How to Use This Skill

- **Without arguments** — load core frameworks for reference
- **With a pattern name** — ask about `Singleton`, `Visitor`, `Bridge`...; I find and read the relevant chapter
- **With a problem** — describe what varies in your design; I apply the selection decision rules from the cheatsheet
- **With chapter** — ask for `ch03`; I load that specific chapter
- **Browse** — ask "what chapters do you have?" to see the full index

When you ask about a topic not covered in Core Frameworks below, I will read
the relevant chapter file before answering.

---

## Core Frameworks & Mental Models

**The two organizing principles of the whole book:**
1. **Program to an interface, not an implementation** — clients commit to abstract classes; factories create the concrete ones.
2. **Favor object composition over class inheritance** — run-time, black-box reuse beats compile-time, white-box reuse. Inheritance leaks parent internals; composition doesn't.

**The master selection heuristic** — *encapsulate the concept that varies*. Identify the axis of change in your design; the pattern that encapsulates that axis is the candidate:

- What varies in *creation* → Abstract Factory (families), Factory Method (subclass), Prototype (instance), Builder (construction process), Singleton (count).
- What varies in *structure* → Adapter (interface), Bridge (implementation), Composite (part-whole), Decorator (responsibilities), Facade (subsystem interface), Flyweight (storage), Proxy (access).
- What varies in *behavior* → Strategy (algorithm), State (state-dependent behavior), Command (request as data), Memento (state snapshots), Observer (dependents), Mediator (peer interaction), Iterator (traversal), Visitor (operations), Chain of Responsibility (handler), Template Method (steps), Interpreter (grammar).

**Key disambiguations the book insists on:**
- **Adapter vs Bridge**: Adapter fixes an interface mismatch after the fact; Bridge is designed up-front so two axes vary independently.
- **Decorator vs Proxy vs Composite**: same structure, different intent — Decorator adds behavior, Proxy controls access, Composite aggregates children.
- **Strategy vs State**: Strategy is stateless and interchangeable; State knows its transitions.
- **Visitor's price**: easy to add operations, expensive to add element classes. Only when the structure is stable.
- **Template Method = inversion of control**: "don't call us, we'll call you" — the base class drives, subclasses hook in.

**Anti-pattern stance (Ch 1.8)** — *never apply patterns indiscriminately*: patterns buy flexibility with indirection; apply only when that flexibility is actually needed. The Consequences sections are the real content of every pattern.

**Pattern description template (13 sections)**: Name / Intent / Also Known As / Motivation / Applicability / Structure / Participants / Collaborations / Consequences / Implementation / Sample Code / Known Uses / Related Patterns — use it to document your own patterns.

---

## Chapter Index

| # | Title | Key Frameworks |
|---|-------|----------------|
| [ch01](chapters/ch01-introduction.md) | Introduction | program-to-interface, composition-over-inheritance, pattern template, MVC example |
| [ch02](chapters/ch02-case-study-lexi.md) | Case Study: Lexi document editor | Composite, Strategy, Decorator, Abstract Factory, Bridge, Command, Visitor — forces-first reasoning |
| [ch03](chapters/ch03-creational.md) | Creational Patterns | Abstract Factory, Builder, Factory Method, Prototype, Singleton |
| [ch04](chapters/ch04-structural.md) | Structural Patterns | Adapter, Bridge, Composite, Decorator, Facade, Flyweight, Proxy |
| [ch05](chapters/ch05-behavioral.md) | Behavioral Patterns | Chain of Responsibility, Command, Interpreter, Iterator, Mediator, Memento, Observer, State, Strategy, Template Method, Visitor |
| [ch06](chapters/ch06-conclusion.md) | Conclusion | common vocabulary, refactoring targets, expansion/consolidation cycle |

## Topic Index

- **Abstract Factory** → ch03 (case study: ch02)
- **Adapter** → ch04
- **Builder** → ch03
- **Chain of Responsibility** → ch05
- **Command** → ch05 (case study: ch02)
- **Composition vs inheritance** → ch01, ch06
- **Composite** → ch04 (case study: ch02)
- **Decorator** → ch04 (case study: ch02)
- **Delegation** → ch01
- **Double dispatch** → ch05 (Visitor)
- **Facade** → ch04
- **Factory Method** → ch03
- **Flyweight** → ch04
- **Framework design / inversion of control** → ch01, ch05
- **Interpreter** → ch05
- **Iterator** → ch05 (case study: ch02)
- **Mediator** → ch05
- **Memento** → ch05
- **MVC** → ch01
- **Observer** → ch05
- **Prototype** → ch03
- **Proxy** → ch04
- **Refactoring toward patterns** → ch06
- **Selection of a pattern** → ch01 (1.7), cheatsheet
- **Singleton** → ch03
- **State** → ch05
- **Strategy** → ch05 (case study: ch02)
- **Template Method** → ch05
- **Undo** → ch02, ch05 (Command, Memento)
- **Visitor** → ch05 (case study: ch02)

## Supporting Files

- [glossary.md](glossary.md) — all key terms with definitions
- [patterns.md](patterns.md) — all 23 patterns: when / how / trade-offs
- [cheatsheet.md](cheatsheet.md) — decision rules, disambiguation tables, smells

---

## Scope & Limits

This skill covers the book content only (code examples are modernized Python renditions of the book's C++/Smalltalk idioms, as requested). For hands-on implementation in your codebase, combine with project-specific tools. Note the book predates generics-first languages, functional composition, and concurrency patterns — modern idioms may supersede some implementations (e.g. Singleton) while the *forces* and *intents* remain valid.

Files in this skill

  • SKILL.md6.2 KB
  • chapters/ch01-introduction.md4.2 KB
  • chapters/ch02-case-study-lexi.md4.1 KB
  • chapters/ch03-creational.md9.9 KB
  • chapters/ch04-structural.md11.5 KB
  • chapters/ch05-behavioral.md14.2 KB
  • chapters/ch06-conclusion.md3.8 KB
  • cheatsheet.md5.8 KB
  • glossary.md4.9 KB
  • patterns.md8.8 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.