code-complexity

Featured

Keep each unit comprehensible while the code grows: deep modules over shallow ones, information hiding, honest names, small functions with one job, error handling that does not lose the error, DRY and orthogonality, design by contract, and not leaving broken windows. Merges module-complexity management with naming/function/error-handling discipline and the pragmatic meta-rules. Use when writing or reviewing a function, class or module; when an interface feels wide, a class feels shallow, or a change in one place forces edits in three; when the user says "this is hard to follow", "clean this up", "review this code", "is this a good abstraction", "too many parameters", "pass-through method", "duplicated logic", or asks about naming, comments, error handling or unit tests. Do NOT use to decide where a new module LIVES or which modules exist (use architecture-first), to plan capacity or storage (use system-and-data-design), to execute a named transformation on a file that is already too large (use refactoring-saf

AI & Automation 150 stars 24 forks Updated 5 days ago MIT

Install

View on GitHub

Quality Score: 88/100

Stars 20%
73
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# Code complexity — keeping a unit comprehensible Complexity is not how clever the code is. It is how much you must hold in your head to change one line safely. It accumulates by increments that each look acceptable, which is why it is never one bad commit's fault and always everyone's problem. ## The two symptoms worth memorising **Change amplification** — one decision, many edits. If changing a timeout means editing five files, that decision was not encapsulated anywhere. **Cognitive load** — how much you must know to be safe. A function that is correct only if you know that the caller already took a lock has exported its complexity to everyone who reads it. Both are properties of the *interface*, not the implementation. Which gives the rule: ## Deep over shallow A module's value is `functionality it provides ÷ interface you must learn`. Deep = small interface, substantial behaviour behind it. Shallow = large interface, little behind it. - A pass-through method that only calls one other method with the same arguments is negative value: it adds an interface without adding behaviour. - "One class per concept, many tiny classes" is not automatically good. Many shallow classes cost more total interface than a few deep ones. - The right question is never "is this class small?" but "how much do I need to know to use it?" ## Information hiding — and its inverse Every design decision that might change should be known to exactly one module. The inverse — **informatio...

Details

Author
AnastasiyaW
Repository
AnastasiyaW/codex-claude-code-config
Created
6 months ago
Last Updated
5 days ago
Language
Python
License
MIT

Bundled in these plugins

Similar Skills

Semantically similar based on skill content — not just same category