# Twiced Technology Gmbh Seedr Design Patterns

> Design Patterns

- Skill: `tomevault-io/twiced-technology-gmbh-seedr-design-patterns` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add tomevault-io/twiced-technology-gmbh-seedr-design-patterns`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tomevault-io/twiced-technology-gmbh-seedr-design-patterns/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: tomevault-io (https://skillmd.com/u/tomevault-io)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/tomevault-io/twiced-technology-gmbh-seedr-design-patterns

---


# Design Patterns

Quick reference for the 23 Gang of Four design patterns organized by category.

## How to Respond

When a user asks about design patterns, structure your response with these sections:

1. **Recommendation** — Commit to ONE specific pattern. Do not list multiple options without picking one.
2. **Why This Pattern** — Explain how the user's specific scenario maps to this pattern's intent. Reference their domain language (e.g., "your payment types become Strategy implementations").
3. **Code Example** — Adapt the example to the user's domain. Use their class names, their problem context — not generic Shape/Animal/Product examples. Match the user's programming language if specified; default to TypeScript if unspecified.
4. **Trade-offs** — Mention at least one caveat, alternative, or situation where this pattern would be the wrong choice.

If the user explicitly asks to implement a specific pattern, skip the recommendation section and focus on why, domain-adapted code, and trade-offs.

Before responding, consult the relevant reference file (references/creational.md, references/structural.md, or references/behavioral.md) for the pattern's participants, when-to-use criteria, and caveats to ensure accuracy.

## Pattern Selection Guide

| Problem | Consider |
|---------|----------|
| Complex object creation | Factory Method, Abstract Factory, Builder |
| Clone existing objects | Prototype |
| Single shared instance | Singleton |
| Incompatible interfaces | Adapter |
| Separate abstraction from implementation | Bridge |
| Tree structures | Composite |
| Add behavior dynamically | Decorator |
| Simplify complex subsystems | Facade |
| Many similar objects (memory) | Flyweight |
| Control access/lazy loading | Proxy |
| Sequential handlers | Chain of Responsibility |
| Encapsulate requests as objects | Command |
| Traverse collections | Iterator |
| Reduce coupling between components | Mediator |
| Save/restore state (undo) | Memento |
| Event notification | Observer |
| Object behavior varies by state | State |
| Interchangeable algorithms | Strategy |
| Algorithm skeleton with variable steps | Template Method |
| Operations on object structures | Visitor |

## Pattern Categories

### Creational Patterns
Object creation mechanisms. See [references/creational.md](references/creational.md).

| Pattern | Intent |
|---------|--------|
| **Factory Method** | Defer instantiation to subclasses |
| **Abstract Factory** | Create families of related objects |
| **Builder** | Construct complex objects step-by-step |
| **Prototype** | Clone existing objects |
| **Singleton** | Ensure single instance with global access |

### Structural Patterns
Object composition and relationships. See [references/structural.md](references/structural.md).

| Pattern | Intent |
|---------|--------|
| **Adapter** | Convert interface to another expected interface |
| **Bridge** | Separate abstraction from implementation |
| **Composite** | Treat individual objects and compositions uniformly |
| **Decorator** | Add responsibilities dynamically |
| **Facade** | Simplified interface to complex subsystem |
| **Flyweight** | Share state to support many fine-grained objects |
| **Proxy** | Placeholder controlling access to another object |

### Behavioral Patterns
Object interaction and responsibility distribution. See [references/behavioral.md](references/behavioral.md).

| Pattern | Intent |
|---------|--------|
| **Chain of Responsibility** | Pass request along handler chain |
| **Command** | Encapsulate request as object |
| **Iterator** | Sequential access without exposing representation |
| **Mediator** | Centralize complex communications |
| **Memento** | Capture and restore object state |
| **Observer** | Notify dependents of state changes |
| **State** | Alter behavior when state changes |
| **Strategy** | Interchangeable algorithm family |
| **Template Method** | Define algorithm skeleton, defer steps to subclasses |
| **Visitor** | Add operations without modifying classes |

## Quick Implementation Examples

### Factory Method (TypeScript)
```typescript
interface Product { operation(): string }

abstract class Creator {
  abstract createProduct(): Product
  doSomething(): string {
    const product = this.createProduct()
    return product.operation()
  }
}

class ConcreteCreator extends Creator {
  createProduct(): Product { return new ConcreteProduct() }
}
```

### Strategy (TypeScript)
```typescript
interface Strategy { execute(data: string[]): string[] }

class Context {
  constructor(private strategy: Strategy) {}
  setStrategy(strategy: Strategy) { this.strategy = strategy }
  doWork(data: string[]): string[] { return this.strategy.execute(data) }
}

// Usage: context.setStrategy(new SortAscending())
```

### Observer (TypeScript)
```typescript
interface Observer { update(state: any): void }

class Subject {
  private observers: Observer[] = []
  attach(o: Observer) { this.observers.push(o) }
  detach(o: Observer) { this.observers = this.observers.filter(x => x !== o) }
  notify(state: any) { this.observers.forEach(o => o.update(state)) }
}
```

### Decorator (TypeScript)
```typescript
interface Component { operation(): string }

class ConcreteComponent implements Component {
  operation() { return 'base' }
}

class Decorator implements Component {
  constructor(protected component: Component) {}
  operation() { return this.component.operation() }
}

class ConcreteDecorator extends Decorator {
  operation() { return `decorated(${super.operation()})` }
}
```

## Resources

For detailed explanations, participants, and when-to-use guidance:

- [references/creational.md](references/creational.md) - Factory Method, Abstract Factory, Builder, Prototype, Singleton
- [references/structural.md](references/structural.md) - Adapter, Bridge, Composite, Decorator, Facade, Flyweight, Proxy
- [references/behavioral.md](references/behavioral.md) - Chain of Responsibility, Command, Iterator, Mediator, Memento, Observer, State, Strategy, Template Method, Visitor

---
> Converted and distributed by [TomeVault](https://tomevault.io/claim/twiced-technology-gmbh) — claim your Tome and manage your conversions.
<!-- tomevault:4.0:skill_md:2026-04-14 -->

