Skip to content
aposd-designing-deep-modules logo

Skill: aposd-designing-deep-modules

aposd-designing-deep-modules

Guides module and API design using APOSD principles: generates multiple design alternatives, compares them on information hiding and interface depth, and produces a documented design decision.

ryanthedev/code-foundations0installs376stars

SKILL.md

Full skill instructions

Skill: aposd-designing-deep-modules

STOP - Before Implementing

Never implement your first design. Generate 2-3 radically different approaches, compare them, then implement.


Design-It-Twice Workflow

BEFORE implementing any module:

1. DEFINE - What are you designing? (class, API, service)
2. GENERATE - 2-3 RADICALLY different approaches
3. SKETCH - Rough outline each (important methods only, no implementation)
4. COMPARE - List pros/​cons, especially ease of use for callers
5. EVALUATE - Is there a clear winner or hybrid?
6. VERIFY - Does chosen design pass depth evaluation?
7. IMPLEMENT - Only then write the code

If none attractive: Use identified problems to drive a new iteration of step 2.


Depth Evaluation

MetricDeep (Good)Shallow (Bad)
Interface sizeFew methodsMany methods
Method reusabilityMultiple use casesSingle use case
Hidden informationHighLow
Caller cognitive loadLowHigh
Common caseSimpleComplex

Exemplar: Unix file I/​O - 5 methods hide hundreds of thousands of lines of implementation.


Three Questions Framework

Ask these when designing interfaces:

QuestionPurposeRed Flag Answer
"What is the simplest interface that covers all current needs?"Minimize method count"I need many methods"
"In how many situations will this method be used?"Detect over-specialization"Just this one situation"
"Is this easy to use for my current needs?"Guard against over-generalization"I need lots of wrapper code"

Information Hiding Checklist

When embedding functionality in a module:

  • Data structures and algorithms stay internal
  • Lower-level details (page sizes, buffer sizes) hidden
  • Higher-level assumptions (most files are small) hidden
  • No knowledge shared across module boundaries unnecessarily
  • Common case requires no knowledge of internal details

Generality Sweet Spot

Target: Somewhat general-purpose

AspectShould Be
FunctionalityReflects current needs
InterfaceSupports multiple uses
SpecializationPushed up to callers OR down into variants

Push specialization UP: Top-level code handles specific features; lower layers stay general.

Push specialization DOWN: Define general interface, implement with device-specific variants.


Red Flags

Red FlagSymptomFix
Shallow ModuleInterface complexity rivals implementationCombine with related functionality
ClassitisMany small classes with little functionality eachConsolidate related classes
Single-Use MethodMethod designed for exactly one callerGeneralize to handle multiple cases
Information LeakageSame knowledge in multiple modulesConsolidate in single module
Temporal DecompositionStructure mirrors execution orderStructure by knowledge encapsulation
False AbstractionInterface hides info caller actually needsExpose necessary information
Granularity MismatchCaller must do work that belongs in moduleMove logic into module
Silent FailureModule handles errors internally but gives callers no way to know something went wrong (no error return, no observable state change, no logging)Errors are implementation details that can be hidden; failures are not — surface failure states even when hiding the mechanism

Mandatory Output Format

When designing, produce:

## Design: [Component Name]

### Approaches Considered
1. [Approach A] - [1-2 sentence description]
2. [Approach B] - [1-2 sentence description]
3. [Approach C] - [1-2 sentence description] (if applicable)

### Comparison
| Criterion | A | B | C |
|-----------|---|---|---|
| Interface simplicity | | | |
| Information hiding | | | |
| Caller ease of use | | | |
| [Domain-specific criterion] | | | |

### Choice: [A/​B/​C/​Hybrid]
Rationale: [Why this wins, what's sacrificed]

### Depth Check
- Interface methods: [count]
- Hidden details: [list]
- Common case complexity: [simple/​moderate/​complex]

Chain

AfterNext
Design chosenRead(${CLAUDE_PLUGIN_ROOT}/​skills/​cc-pseudocode-programming/​SKILL.md)

More skills from ryanthedev

cc-defensive-programming logo
ryanthedev/code-foundations

cc-defensive-programming

Applies Code Complete's defensive programming rules: barricade design, assertion vs error-handling selection, input validation policy, and correctness-vs-robustness strategy for the current context.

376 0
View
cc-pseudocode-programming logo
ryanthedev/code-foundations

cc-pseudocode-programming

Structures routine design through pseudocode-first iteration: clarifies naming and purpose before any code, catches design flaws cheaply, and prevents compile-debug loops on poorly understood routines.

376 0
View
aposd-simplifying-complexity logo
ryanthedev/code-foundations

aposd-simplifying-complexity

Transforms complex code by applying APOSD's pull-complexity-downward principle: resolves error hierarchies, collapses configuration, and moves caller-side logic into modules. Produces edited code, not just assessment.

376 0
View
cc-refactoring-guidance logo
ryanthedev/code-foundations

cc-refactoring-guidance

Guides safe refactoring using Code Complete's fix-first-then-refactor discipline: decides between refactor, rewrite, and fix-first; enforces separate commits; applies small-change rigor to high-error-rate one-liners.

376 0
View
aposd-reviewing-module-design logo
ryanthedev/code-foundations

aposd-reviewing-module-design

Assesses existing module and interface design for complexity symptoms: information leakage, shallow interfaces, pass-through layers, and unknown unknowns. Produces a structured assessment — not transformations.

376 0
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View