{"id":"6b09a4b6ff996234422a26ba","slug":"kiss","title":"KISS: the simplest working solution usually wins","summary":"The KISS principle through the delivery fee in Halina's pierogi place: essential vs accidental complexity, signs of over-engineering, refactoring a “clever” rule engine into a single function in C#, TypeScript, Java, Go and Python, and complexity metrics.","servedLang":"en","availableLangs":["pl","en"],"topics":["kiss","yagni"],"techs":["dotnet","typescript","java","go","python"],"tags":["kiss","principles","simplicity","refactoring","cyclomatic-complexity","over-engineering"],"level":"beginner","kind":"article","access":"public","status":"published","cover":null,"author":{"id":"6b08bd2e80884893657cc8cf","name":"Redakcja Art of Devs","avatar":null,"handle":"redakcja","community":false},"readingMinutes":20,"stats":{"views":2,"likes":0,"bookmarks":0,"comments":0},"publishedAt":"2026-11-27T15:41:42.533Z","updatedAt":"2026-11-27T17:31:33.334Z","requestedLang":"en","theme":{"hero":"classic","heroMedia":null,"accent":"amber","background":"dots","weaveResources":true,"toc":"right"},"seoDescription":"KISS (Keep It Simple) in practice: essential vs accidental complexity, signs of over-engineering, before/after refactoring in C#, TypeScript, Java, Go and Python, cyclomatic and cognitive complexity, tools and code review tips.","wordCount":3864,"doc":{"type":"doc","content":[{"type":"paragraph","content":[{"type":"text","text":"The delivery fee in Halina's pierogi place is three sentences in the terms of service: orders from 120 zł ship free, up to 3 km costs 7 zł, and every started kilometre beyond that adds 2 zł; we don't go further than 10 km. In the code, those three sentences turned into a rule engine with priorities, a dictionary of objects and seven types. "},{"type":"text","text":"KISS","marks":[{"type":"bold"}]},{"type":"text","text":" ("},{"type":"text","text":"Keep It Simple, Stupid","marks":[{"type":"italic"}]},{"type":"text","text":") reminds us that a solution should be as complex as the problem, not as complex as its author's ambitions."}]},{"type":"callout","attrs":{"variant":"tip","title":"In short"},"content":[{"type":"bulletList","content":[{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Tell "},{"type":"text","text":"essential complexity","marks":[{"type":"bold"}]},{"type":"text","text":" (it comes from the problem) from "},{"type":"text","text":"accidental complexity","marks":[{"type":"bold"}]},{"type":"text","text":" (we added it ourselves)."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Simplicity means few parts and few connections between them, not few lines."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"\"Simple\" does not mean \"simplistic\": simple code still handles every real rule and edge case."}]}]}]}]},{"type":"stats","attrs":{"items":[{"value":"1986","label":"the \"No Silver Bullet\" essay","hint":"Fred Brooks splits complexity into essential and accidental"},{"value":"10","label":"cyclomatic complexity threshold","hint":"proposed by Thomas McCabe in 1976"},{"value":"7 → 1","label":"types in our example","hint":"before and after the refactoring"}]}},{"type":"heading","attrs":{"level":2,"id":"where-kiss-comes-from"},"content":[{"type":"text","text":"Where KISS comes from"}]},{"type":"paragraph","content":[{"type":"text","text":"The acronym is attributed to Kelly Johnson, lead engineer of Lockheed's Skunk Works. An aircraft had to be repairable in the field by an average mechanic with basic tools. In software, that mechanic is the colleague who opens your code at 2 a.m. six months from now because customers cannot place orders."}]},{"type":"paragraph","content":[{"type":"text","text":"The second source, more important for programmers, is Fred Brooks's essay "},{"type":"text","text":"No Silver Bullet","marks":[{"type":"italic"}]},{"type":"text","text":" (1986). Brooks splits the difficulties of building software into "},{"type":"text","text":"essential","marks":[{"type":"bold"}]},{"type":"text","text":" ones – inherent in the problem itself – and "},{"type":"text","text":"accidental","marks":[{"type":"bold"}]},{"type":"text","text":" ones – coming from our tools and the way we solve the problem. Essential complexity cannot be removed; at best you can name it well and keep it organised. Accidental complexity can, and should, be kept to a minimum."}]},{"type":"table","content":[{"type":"tableRow","content":[{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph"}]},{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Essential complexity"}]}]},{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Accidental complexity"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Source"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"terms of service, law, physics, customer expectations"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"our design decisions and tools"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"In the delivery fee"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"the 120 zł threshold, 7 zł up to 3 km, rounding kilometres up, the 10 km limit"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"rule priorities, a "},{"type":"text","text":"string → object","marks":[{"type":"code"}]},{"type":"text","text":" dictionary, type casts, the engine"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"What to do with it"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"name it, test it, keep it in one place"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"remove it or keep it to a minimum"}]}]}]}]},{"type":"heading","attrs":{"level":2,"id":"the-problem-a-rule-engine-for-three-sentences"},"content":[{"type":"text","text":"The problem: a rule engine for three sentences"}]},{"type":"paragraph","content":[{"type":"text","text":"The developer who wrote the delivery module expected the rules to multiply. So they built a \"flexible\" engine: each rule is a class with a priority, data goes into a dictionary, and the engine sorts the rules and folds the result. It works – but read the code as if you had to change the free-delivery threshold for the first time."}]},{"type":"codeGroup","attrs":{"title":"Before – delivery fee rule engine"},"content":[{"type":"codeBlock","attrs":{"language":"csharp","filename":"FeeEngine.cs"},"content":[{"type":"text","text":"// Before: a \"flexible\" rule engine for three business rules.\nvar engine = new FeeEngine([new DistanceFeeRule(7m, 3, 2m), new FreeAboveRule(120m), new MaxDistanceRule(10)]);\nConsole.WriteLine(engine.Calculate(new FeeContext { [\"total\"] = 80m, [\"km\"] = 4.2 })); // 11\n// new FeeContext { [\"total\"] = 80m, [\"km\"] = 4 } -> InvalidCastException at runtime\n\npublic sealed class FeeContext : Dictionary<string, object>; // weakly typed bag\npublic sealed record FeeResult(decimal Fee, bool Stop = false, bool Rejected = false);\n\npublic interface IFeeRule\n{\n    int Priority { get; } // lower runs first; the order lives in magic numbers\n    FeeResult Apply(FeeContext ctx, FeeResult current);\n}\n\npublic sealed class MaxDistanceRule(double maxKm) : IFeeRule\n{\n    public int Priority => 0;\n    public FeeResult Apply(FeeContext ctx, FeeResult current) =>\n        (double)ctx[\"km\"] > maxKm ? current with { Stop = true, Rejected = true } : current;\n}\n\npublic sealed class FreeAboveRule(decimal threshold) : IFeeRule\n{\n    public int Priority => 10;\n    public FeeResult Apply(FeeContext ctx, FeeResult current) =>\n        (decimal)ctx[\"total\"] >= threshold ? current with { Fee = 0m, Stop = true } : current;\n}\n\npublic sealed class DistanceFeeRule(decimal baseFee, int includedKm, decimal perKm) : IFeeRule\n{\n    public int Priority => 20;\n    public FeeResult Apply(FeeContext ctx, FeeResult current)\n    {\n        var extraKm = Math.Max(0, (int)Math.Ceiling((double)ctx[\"km\"] - includedKm));\n        return current with { Fee = baseFee + extraKm * perKm };\n    }\n}\n\npublic sealed class FeeEngine(IEnumerable<IFeeRule> rules)\n{\n    private readonly List<IFeeRule> _rules = rules.OrderBy(r => r.Priority).ToList();\n\n    public decimal? Calculate(FeeContext ctx)\n    {\n        var result = new FeeResult(0m);\n        foreach (var rule in _rules)\n        {\n            result = rule.Apply(ctx, result);\n            if (result.Stop) break;\n        }\n        return result.Rejected ? null : result.Fee;\n    }\n}"}]},{"type":"codeBlock","attrs":{"language":"typescript","filename":"fee-engine.ts"},"content":[{"type":"text","text":"// Before: a \"flexible\" rule engine for three business rules.\ntype FeeContext = Record<string, unknown>; // weakly typed bag\ninterface FeeResult { fee: number; stop: boolean; rejected?: boolean } // fee in grosze\n\ninterface FeeRule {\n  readonly priority: number; // lower runs first; the order lives in magic numbers\n  apply(ctx: FeeContext, current: FeeResult): FeeResult;\n}\n\nclass MaxDistanceRule implements FeeRule {\n  readonly priority = 0;\n  constructor(private readonly maxKm: number) {}\n  apply(ctx: FeeContext, cur: FeeResult): FeeResult {\n    return (ctx.km as number) > this.maxKm ? { ...cur, stop: true, rejected: true } : cur;\n  }\n}\n\nclass FreeAboveRule implements FeeRule {\n  readonly priority = 10;\n  constructor(private readonly threshold: number) {}\n  apply(ctx: FeeContext, cur: FeeResult): FeeResult {\n    return (ctx.total as number) >= this.threshold ? { ...cur, fee: 0, stop: true } : cur;\n  }\n}\n\nclass DistanceFeeRule implements FeeRule {\n  readonly priority = 20;\n  constructor(private readonly baseFee: number, private readonly includedKm: number, private readonly perKm: number) {}\n  apply(ctx: FeeContext, cur: FeeResult): FeeResult {\n    const extraKm = Math.max(0, Math.ceil((ctx.km as number) - this.includedKm));\n    return { ...cur, fee: this.baseFee + extraKm * this.perKm };\n  }\n}\n\nclass FeeEngine {\n  private readonly rules: FeeRule[];\n  constructor(rules: FeeRule[]) {\n    this.rules = [...rules].sort((a, b) => a.priority - b.priority);\n  }\n  calculate(ctx: FeeContext): number | null {\n    let result: FeeResult = { fee: 0, stop: false };\n    for (const rule of this.rules) {\n      result = rule.apply(ctx, result);\n      if (result.stop) break;\n    }\n    return result.rejected ? null : result.fee;\n  }\n}\n\nconst engine = new FeeEngine([new DistanceFeeRule(700, 3, 200), new FreeAboveRule(12_000), new MaxDistanceRule(10)]);\nconsole.log(engine.calculate({ total: 8_000, km: 4.2 })); // 1100\nconsole.log(engine.calculate({ total: 8_000, kms: 4.2 })); // typo -> NaN, no error"}]},{"type":"codeBlock","attrs":{"language":"java","filename":"FeeEngine.java"},"content":[{"type":"text","text":"import java.math.BigDecimal;\nimport java.util.Comparator;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.Optional;\n\n// Before: a \"flexible\" rule engine for three business rules.\npublic class FeeEngine {\n    private final List<FeeRule> rules;\n\n    FeeEngine(List<FeeRule> rules) {\n        this.rules = rules.stream().sorted(Comparator.comparingInt(FeeRule::priority)).toList();\n    }\n\n    Optional<BigDecimal> calculate(Map<String, Object> ctx) { // weakly typed bag\n        var result = new FeeResult();\n        for (var rule : rules) {\n            rule.apply(ctx, result);\n            if (result.stop) break;\n        }\n        return result.rejected ? Optional.empty() : Optional.of(result.fee);\n    }\n\n    public static void main(String[] args) {\n        var engine = new FeeEngine(List.of(\n                new DistanceFeeRule(new BigDecimal(\"7\"), 3, new BigDecimal(\"2\")),\n                new FreeAboveRule(new BigDecimal(\"120\")),\n                new MaxDistanceRule(10)));\n        System.out.println(engine.calculate(Map.of(\"total\", new BigDecimal(\"80\"), \"km\", 4.2))); // Optional[11]\n        // Map.of(\"total\", 80, \"km\", 4.2) -> ClassCastException at runtime\n    }\n}\n\nclass FeeResult {\n    BigDecimal fee = BigDecimal.ZERO;\n    boolean stop, rejected;\n}\n\ninterface FeeRule {\n    int priority(); // lower runs first; the order lives in magic numbers\n    void apply(Map<String, Object> ctx, FeeResult result);\n}\n\nrecord MaxDistanceRule(double maxKm) implements FeeRule {\n    public int priority() { return 0; }\n    public void apply(Map<String, Object> ctx, FeeResult r) {\n        if ((double) ctx.get(\"km\") > maxKm) { r.stop = true; r.rejected = true; }\n    }\n}\n\nrecord FreeAboveRule(BigDecimal threshold) implements FeeRule {\n    public int priority() { return 10; }\n    public void apply(Map<String, Object> ctx, FeeResult r) {\n        if (((BigDecimal) ctx.get(\"total\")).compareTo(threshold) >= 0) { r.fee = BigDecimal.ZERO; r.stop = true; }\n    }\n}\n\nrecord DistanceFeeRule(BigDecimal baseFee, int includedKm, BigDecimal perKm) implements FeeRule {\n    public int priority() { return 20; }\n    public void apply(Map<String, Object> ctx, FeeResult r) {\n        int extraKm = Math.max(0, (int) Math.ceil((double) ctx.get(\"km\") - includedKm));\n        r.fee = baseFee.add(perKm.multiply(BigDecimal.valueOf(extraKm)));\n    }\n}"}]},{"type":"codeBlock","attrs":{"language":"go","filename":"fee_engine.go"},"content":[{"type":"text","text":"package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n\t\"sort\"\n)\n\n// Before: a \"flexible\" rule engine for three business rules.\ntype FeeContext map[string]any // weakly typed bag\n\ntype FeeResult struct {\n\tFee      int64 // grosze\n\tStop     bool\n\tRejected bool\n}\n\ntype FeeRule interface {\n\tPriority() int // lower runs first; the order lives in magic numbers\n\tApply(ctx FeeContext, cur FeeResult) FeeResult\n}\n\ntype MaxDistanceRule struct{ MaxKm float64 }\n\nfunc (MaxDistanceRule) Priority() int { return 0 }\nfunc (r MaxDistanceRule) Apply(ctx FeeContext, cur FeeResult) FeeResult {\n\tif ctx[\"km\"].(float64) > r.MaxKm { // panics if someone passes an int\n\t\tcur.Stop, cur.Rejected = true, true\n\t}\n\treturn cur\n}\n\ntype FreeAboveRule struct{ Threshold int64 }\n\nfunc (FreeAboveRule) Priority() int { return 10 }\nfunc (r FreeAboveRule) Apply(ctx FeeContext, cur FeeResult) FeeResult {\n\tif ctx[\"total\"].(int64) >= r.Threshold {\n\t\tcur.Fee, cur.Stop = 0, true\n\t}\n\treturn cur\n}\n\ntype DistanceFeeRule struct {\n\tBaseFee, PerKm int64\n\tIncludedKm     float64\n}\n\nfunc (DistanceFeeRule) Priority() int { return 20 }\nfunc (r DistanceFeeRule) Apply(ctx FeeContext, cur FeeResult) FeeResult {\n\textraKm := math.Max(0, math.Ceil(ctx[\"km\"].(float64)-r.IncludedKm))\n\tcur.Fee = r.BaseFee + int64(extraKm)*r.PerKm\n\treturn cur\n}\n\ntype FeeEngine struct{ rules []FeeRule }\n\nfunc NewFeeEngine(rules ...FeeRule) *FeeEngine {\n\tsort.Slice(rules, func(i, j int) bool { return rules[i].Priority() < rules[j].Priority() })\n\treturn &FeeEngine{rules: rules}\n}\n\nfunc (e *FeeEngine) Calculate(ctx FeeContext) (fee int64, ok bool) {\n\tvar res FeeResult\n\tfor _, rule := range e.rules {\n\t\tif res = rule.Apply(ctx, res); res.Stop {\n\t\t\tbreak\n\t\t}\n\t}\n\treturn res.Fee, !res.Rejected\n}\n\nfunc main() {\n\tengine := NewFeeEngine(DistanceFeeRule{BaseFee: 700, PerKm: 200, IncludedKm: 3}, FreeAboveRule{12000}, MaxDistanceRule{10})\n\tfmt.Println(engine.Calculate(FeeContext{\"total\": int64(8000), \"km\": 4.2})) // 1100 true\n}"}]},{"type":"codeBlock","attrs":{"language":"python","filename":"fee_engine.py"},"content":[{"type":"text","text":"import math\nfrom dataclasses import dataclass, replace\nfrom decimal import Decimal\nfrom typing import Any, Protocol\n\n# Before: a \"flexible\" rule engine for three business rules.\nFeeContext = dict[str, Any]  # weakly typed bag\n\n\n@dataclass(frozen=True)\nclass FeeResult:\n    fee: Decimal = Decimal(\"0\")\n    stop: bool = False\n    rejected: bool = False\n\n\nclass FeeRule(Protocol):\n    priority: int  # lower runs first; the order lives in magic numbers\n\n    def apply(self, ctx: FeeContext, current: FeeResult) -> FeeResult: ...\n\n\n@dataclass\nclass MaxDistanceRule:\n    max_km: float\n    priority: int = 0\n\n    def apply(self, ctx: FeeContext, current: FeeResult) -> FeeResult:\n        return replace(current, stop=True, rejected=True) if ctx[\"km\"] > self.max_km else current\n\n\n@dataclass\nclass FreeAboveRule:\n    threshold: Decimal\n    priority: int = 10\n\n    def apply(self, ctx: FeeContext, current: FeeResult) -> FeeResult:\n        return replace(current, fee=Decimal(\"0\"), stop=True) if ctx[\"total\"] >= self.threshold else current\n\n\n@dataclass\nclass DistanceFeeRule:\n    base_fee: Decimal\n    included_km: int\n    per_km: Decimal\n    priority: int = 20\n\n    def apply(self, ctx: FeeContext, current: FeeResult) -> FeeResult:\n        extra_km = max(0, math.ceil(ctx[\"km\"] - self.included_km))\n        return replace(current, fee=self.base_fee + extra_km * self.per_km)\n\n\nclass FeeEngine:\n    def __init__(self, rules: list[FeeRule]) -> None:\n        self._rules = sorted(rules, key=lambda r: r.priority)\n\n    def calculate(self, ctx: FeeContext) -> Decimal | None:\n        result = FeeResult()\n        for rule in self._rules:\n            result = rule.apply(ctx, result)\n            if result.stop:\n                break\n        return None if result.rejected else result.fee\n\n\nengine = FeeEngine([DistanceFeeRule(Decimal(\"7\"), 3, Decimal(\"2\")), FreeAboveRule(Decimal(\"120\")), MaxDistanceRule(10)])\nprint(engine.calculate({\"total\": Decimal(\"80\"), \"km\": 4.2}))  # 11"}]}]},{"type":"paragraph","content":[{"type":"text","text":"What is wrong, if every class on its own is short?"}]},{"type":"bulletList","content":[{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Rule order hidden in numbers.","marks":[{"type":"bold"}]},{"type":"text","text":" To know that the 10 km limit is checked before free delivery, you have to compare "},{"type":"text","text":"Priority","marks":[{"type":"code"}]},{"type":"text","text":" across three files."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Weak typing.","marks":[{"type":"bold"}]},{"type":"text","text":" A "},{"type":"text","text":"string → object","marks":[{"type":"code"}]},{"type":"text","text":" dictionary switches the compiler off. A typo like "},{"type":"text","text":"kms","marks":[{"type":"code"}]},{"type":"text","text":" in TypeScript yields "},{"type":"text","text":"NaN","marks":[{"type":"code"}]},{"type":"text","text":" instead of an error, and in C#, Java and Go an integer where a float was expected ends in an exception (or a "},{"type":"text","text":"panic","marks":[{"type":"code"}]},{"type":"text","text":") only in the running application."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Flexibility nobody uses.","marks":[{"type":"bold"}]},{"type":"text","text":" In two years the rules changed once – the threshold went from 100 to 120 zł. The engine was meant to make adding rules easy; instead it makes it harder to change the only number that ever changes."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"The tests test the engine, not the rules.","marks":[{"type":"bold"}]},{"type":"text","text":" Half of them check sorting and the "},{"type":"text","text":"Stop","marks":[{"type":"code"}]},{"type":"text","text":" flag, not what a customer on Długa Street will pay."}]}]}]},{"type":"diagram","attrs":{"kind":"mermaid","code":"flowchart LR\n  subgraph Before[\"Before: rule engine\"]\n    K1[\"Cart\"] --> E[\"FeeEngine\"]\n    E -->|\"sorts by Priority\"| R1[\"MaxDistanceRule\"]\n    E --> R2[\"FreeAboveRule\"]\n    E --> R3[\"DistanceFeeRule\"]\n    R1 -.->|\"casts\"| C[(\"FeeContext<br/>string → object\")]\n    R2 -.-> C\n    R3 -.-> C\n  end\n  subgraph After[\"After: one function\"]\n    K2[\"Cart\"] --> F[\"Delivery.Fee(total, km)\"]\n  end","caption":"From the cart to the fee: before and after the refactoring"}},{"type":"heading","attrs":{"level":2,"id":"refactoring-from-clever-to-simple"},"content":[{"type":"text","text":"Refactoring: from clever to simple"}]},{"type":"paragraph","content":[{"type":"text","text":"The simple version writes the rules down exactly as they read: first the distance limit, then free delivery, finally the per-kilometre fee. Constants have names, the compiler checks the types, and the order of the conditions is the order of reading."}]},{"type":"codeGroup","attrs":{"title":"After – the delivery fee as one function"},"content":[{"type":"codeBlock","attrs":{"language":"csharp","filename":"Delivery.cs"},"content":[{"type":"text","text":"Console.WriteLine(Show(Delivery.Fee(orderTotal: 80m, distanceKm: 4.2)));  // 11\nConsole.WriteLine(Show(Delivery.Fee(orderTotal: 150m, distanceKm: 4.2))); // 0\nConsole.WriteLine(Show(Delivery.Fee(orderTotal: 80m, distanceKm: 12)));   // no delivery\n\nstatic string Show(decimal? fee) => fee?.ToString() ?? \"no delivery\";\n\npublic static class Delivery\n{\n    public const double MaxDistanceKm = 10;\n    public const decimal FreeFrom = 120m;\n    public const decimal BaseFee = 7m;    // covers the first 3 km\n    public const int IncludedKm = 3;\n    public const decimal PerExtraKm = 2m; // for every started kilometre above that\n\n    /// <summary>Returns null when the address is outside the delivery area.</summary>\n    public static decimal? Fee(decimal orderTotal, double distanceKm)\n    {\n        if (distanceKm > MaxDistanceKm) return null;\n        if (orderTotal >= FreeFrom) return 0m;\n\n        var extraKm = Math.Max(0, (int)Math.Ceiling(distanceKm - IncludedKm));\n        return BaseFee + extraKm * PerExtraKm;\n    }\n}"}]},{"type":"codeBlock","attrs":{"language":"typescript","filename":"delivery.ts"},"content":[{"type":"text","text":"// Amounts in grosze (integers): no floating-point surprises with money.\nexport const MAX_DISTANCE_KM = 10;\nexport const FREE_FROM = 12_000;\nexport const BASE_FEE = 700;     // covers the first 3 km\nexport const INCLUDED_KM = 3;\nexport const PER_EXTRA_KM = 200; // for every started kilometre above that\n\n/** Returns null when the address is outside the delivery area. */\nexport function deliveryFee(orderTotal: number, distanceKm: number): number | null {\n  if (distanceKm > MAX_DISTANCE_KM) return null;\n  if (orderTotal >= FREE_FROM) return 0;\n\n  const extraKm = Math.max(0, Math.ceil(distanceKm - INCLUDED_KM));\n  return BASE_FEE + extraKm * PER_EXTRA_KM;\n}\n\nconsole.log(deliveryFee(8_000, 4.2));  // 1100\nconsole.log(deliveryFee(15_000, 4.2)); // 0\nconsole.log(deliveryFee(8_000, 12));   // null"}]},{"type":"codeBlock","attrs":{"language":"java","filename":"Delivery.java"},"content":[{"type":"text","text":"import java.math.BigDecimal;\nimport java.util.Optional;\n\npublic final class Delivery {\n    static final double MAX_DISTANCE_KM = 10;\n    static final BigDecimal FREE_FROM = new BigDecimal(\"120\");\n    static final BigDecimal BASE_FEE = new BigDecimal(\"7\");     // covers the first 3 km\n    static final int INCLUDED_KM = 3;\n    static final BigDecimal PER_EXTRA_KM = new BigDecimal(\"2\"); // for every started kilometre above that\n\n    private Delivery() {}\n\n    /** Empty when the address is outside the delivery area. */\n    static Optional<BigDecimal> fee(BigDecimal orderTotal, double distanceKm) {\n        if (distanceKm > MAX_DISTANCE_KM) return Optional.empty();\n        if (orderTotal.compareTo(FREE_FROM) >= 0) return Optional.of(BigDecimal.ZERO);\n\n        int extraKm = Math.max(0, (int) Math.ceil(distanceKm - INCLUDED_KM));\n        return Optional.of(BASE_FEE.add(PER_EXTRA_KM.multiply(BigDecimal.valueOf(extraKm))));\n    }\n\n    public static void main(String[] args) {\n        System.out.println(fee(new BigDecimal(\"80\"), 4.2));  // Optional[11]\n        System.out.println(fee(new BigDecimal(\"150\"), 4.2)); // Optional[0]\n        System.out.println(fee(new BigDecimal(\"80\"), 12));   // Optional.empty\n    }\n}"}]},{"type":"codeBlock","attrs":{"language":"go","filename":"delivery.go"},"content":[{"type":"text","text":"package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\n// Amounts in grosze (integers): no floating-point surprises with money.\nconst (\n\tMaxDistanceKm = 10.0\n\tFreeFrom      = 12000\n\tBaseFee       = 700 // covers the first 3 km\n\tIncludedKm    = 3.0\n\tPerExtraKm    = 200 // for every started kilometre above that\n)\n\n// DeliveryFee returns ok == false when the address is outside the delivery area.\nfunc DeliveryFee(orderTotal int64, distanceKm float64) (fee int64, ok bool) {\n\tif distanceKm > MaxDistanceKm {\n\t\treturn 0, false\n\t}\n\tif orderTotal >= FreeFrom {\n\t\treturn 0, true\n\t}\n\textraKm := int64(math.Max(0, math.Ceil(distanceKm-IncludedKm)))\n\treturn BaseFee + extraKm*PerExtraKm, true\n}\n\nfunc main() {\n\tfmt.Println(DeliveryFee(8000, 4.2))  // 1100 true\n\tfmt.Println(DeliveryFee(15000, 4.2)) // 0 true\n\tfmt.Println(DeliveryFee(8000, 12))   // 0 false\n}"}]},{"type":"codeBlock","attrs":{"language":"python","filename":"delivery.py"},"content":[{"type":"text","text":"import math\nfrom decimal import Decimal\n\nMAX_DISTANCE_KM = 10\nFREE_FROM = Decimal(\"120\")\nBASE_FEE = Decimal(\"7\")  # covers the first 3 km\nINCLUDED_KM = 3\nPER_EXTRA_KM = Decimal(\"2\")  # for every started kilometre above that\n\n\ndef delivery_fee(order_total: Decimal, distance_km: float) -> Decimal | None:\n    \"\"\"Return the delivery fee, or None when the address is outside the delivery area.\"\"\"\n    if distance_km > MAX_DISTANCE_KM:\n        return None\n    if order_total >= FREE_FROM:\n        return Decimal(\"0\")\n    extra_km = max(0, math.ceil(distance_km - INCLUDED_KM))\n    return BASE_FEE + extra_km * PER_EXTRA_KM\n\n\nprint(delivery_fee(Decimal(\"80\"), 4.2))  # 11\nprint(delivery_fee(Decimal(\"150\"), 4.2))  # 0\nprint(delivery_fee(Decimal(\"80\"), 12))  # None"}]}]},{"type":"paragraph","content":[{"type":"text","text":"Note two details that are "},{"type":"text","text":"not","marks":[{"type":"bold"}]},{"type":"text","text":" accidental complexity: rounding kilometres up ("},{"type":"text","text":"Ceiling","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"ceil","marks":[{"type":"code"}]},{"type":"text","text":") and the type of the amount. In C#, Java and Python we use decimal types ("},{"type":"text","text":"decimal","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"BigDecimal","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"Decimal","marks":[{"type":"code"}]},{"type":"text","text":"); in TypeScript and Go, integers in grosze. Those are requirements of money, not decoration."}]},{"type":"timeline","attrs":{"items":[{"date":"Step 1","title":"Write the rule as sentences","text":"The three sentences from the terms of service are the specification. If you cannot compare the code with them line by line, something is too much."},{"date":"Step 2","title":"Pin the behaviour with tests","text":"Before you delete anything, record the cases: 80 zł and 4.2 km → 11 zł, 150 zł → 0 zł, 12 km → no delivery, exactly 3 km → 7 zł."},{"date":"Step 3","title":"Inline the abstractions","text":"Move the body of every rule into one function, in priority order. Replace the dictionary with typed parameters."},{"date":"Step 4","title":"Delete what is dead","text":"The interface, the engine, the result record and rule registration no longer have users – remove them together with their tests."},{"date":"Step 5","title":"Name the constants","text":"The threshold, the base fee and the limit get names. When the terms change, you change one line."}]}},{"type":"heading","attrs":{"level":2,"id":"how-to-measure-complexity"},"content":[{"type":"text","text":"How to measure complexity"}]},{"type":"paragraph","content":[{"type":"text","text":"Cyclomatic complexity","marks":[{"type":"bold"}]},{"type":"text","text":", proposed by Thomas McCabe in 1976, is the number of independent paths through a function. In practice you count decision points ("},{"type":"text","text":"if","marks":[{"type":"code"}]},{"type":"text","text":", a loop, "},{"type":"text","text":"case","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"&&","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"||","marks":[{"type":"code"}]},{"type":"text","text":", the "},{"type":"text","text":"?:","marks":[{"type":"code"}]},{"type":"text","text":" operator) and add one. The "},{"type":"text","text":"Fee","marks":[{"type":"code"}]},{"type":"text","text":" function has two "},{"type":"text","text":"if","marks":[{"type":"code"}]},{"type":"text","text":"s, so its complexity is 3 – and three test cases are enough to walk every path."}]},{"type":"paragraph","content":[{"type":"text","text":"The catch: cyclomatic complexity looks at "},{"type":"text","text":"one function","marks":[{"type":"bold"}]},{"type":"text","text":". Over-engineered code often has short methods with a complexity of 1–2, while the real difficulty sits between them – in the number of types, the indirection layers and the implicit ordering. That is why it pays to look at several measures at once."}]},{"type":"chart","attrs":{"type":"bar","title":"Delivery fee: before and after the refactoring","caption":"Illustrative values counted by hand for the C# version; tools may count slightly differently.","data":{"labels":["Types (classes, interfaces, records)","Total cyclomatic complexity","Highest complexity of a single method","Files to open to understand the rule"],"series":[{"name":"Before (rule engine)","values":[7,13,4,7]},{"name":"After (one function)","values":[1,3,3,1]}]}}},{"type":"paragraph","content":[{"type":"text","text":"The chart shows why method-level cyclomatic complexity is not enough: the most complex method \"before\" scores 4, \"after\" scores 3. The difference only shows up in the total and in the number of types. A useful complement is "},{"type":"text","text":"cognitive complexity","marks":[{"type":"bold"}]},{"type":"text","text":", developed by SonarSource. It penalises nesting and breaks in the flow ("},{"type":"text","text":"break","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"continue","marks":[{"type":"code"}]},{"type":"text","text":", recursion) – what tires a reader, not just the number of paths to test."}]},{"type":"heading","attrs":{"level":2,"id":"simple-not-simplistic"},"content":[{"type":"text","text":"Simple, not simplistic"}]},{"type":"paragraph","content":[{"type":"text","text":"Simplicity is not about throwing away whatever is inconvenient. A simplistic solution is shorter because it skips part of the problem – and that part comes back as a production bug:"}]},{"type":"codeBlock","attrs":{"language":"typescript","filename":"delivery-simplistic.ts"},"content":[{"type":"text","text":"// Simplistic: shorter, but it quietly drops two business rules and uses floats for money.\nconst fee = (total: number, km: number) => (total >= 120 ? 0 : 7 + (km - 3) * 2);\nfee(80, 4.2); // 9.4 – no rounding up, and 12 km would happily cost 25\nfee(80, 1);   // 3 – below the base fee, because nobody handled km < 3"}]},{"type":"paragraph","content":[{"type":"text","text":"Other \"simplifications\" that are really bugs:"}]},{"type":"bulletList","content":[{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"amounts in "},{"type":"text","text":"float","marks":[{"type":"code"}]},{"type":"text","text":" or "},{"type":"text","text":"double","marks":[{"type":"code"}]},{"type":"text","text":" instead of a decimal type or integer grosze;"}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"dates without a time zone (\"everyone is in Poland anyway\" – until the first clock change, when orders placed at 2:30 a.m. vanish from the report);"}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"payments without idempotency or retries (\"the network works, doesn't it?\");"}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"global state instead of a passed-in dependency – fewer parameters, but tests start depending on each other."}]}]}]},{"type":"paragraph","content":[{"type":"text","text":"A good test of simplicity: you can explain the code in two minutes "},{"type":"text","text":"without saying \"but\"","marks":[{"type":"bold"}]},{"type":"text","text":". Simplistic code can be explained quickly too – and then someone from the business asks: \"what about delivery at 12 km?\"."}]},{"type":"diagram","attrs":{"kind":"mermaid","code":"flowchart TD\n  A[\"Design element:<br/>class, layer, parameter\"] --> Q1{\"Does it come from requirements<br/>or constraints?\"}\n  Q1 -->|yes| ESS[\"Essential complexity:<br/>name it, test it, keep it\"]\n  Q1 -->|no| Q2{\"Does anyone use it<br/>today, not 'some day'?\"}\n  Q2 -->|no| DEL[\"Delete it\"]\n  Q2 -->|yes| Q3{\"Can it be simpler<br/>with the same tests?\"}\n  Q3 -->|yes| SIMP[\"Simplify\"]\n  Q3 -->|no| KEEP[\"Keep it and document why\"]","caption":"Is this complexity needed?"}},{"type":"heading","attrs":{"level":2,"id":"signs-of-over-engineering"},"content":[{"type":"text","text":"Signs of over-engineering"}]},{"type":"bulletList","content":[{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"An interface with a single implementation that you do not replace even in tests."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Configuration and parameters \"just in case\" that nobody has ever changed."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"A home-grown mini-framework: "},{"type":"text","text":"Engine","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"Manager","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"Processor","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"Registry","marks":[{"type":"code"}]},{"type":"text","text":" in names, reflection, registration through annotations."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"string → object","marks":[{"type":"code"}]},{"type":"text","text":" dictionaries, "},{"type":"text","text":"map[string]any","marks":[{"type":"code"}]},{"type":"text","text":" or "},{"type":"text","text":"**kwargs","marks":[{"type":"code"}]},{"type":"text","text":" passed through several layers."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Pass-through methods: a layer that only calls the next one with the same arguments."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"To understand one business rule you open five files."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Tests have more mocks than assertions."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"\"Clever\" one-liners: nested "},{"type":"text","text":"?:","marks":[{"type":"code"}]},{"type":"text","text":" operators, regular expressions for everything, bit tricks instead of readable conditions."}]}]}]},{"type":"pullQuote","attrs":{"text":"Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how will you ever debug it?","author":"Brian W. Kernighan and P. J. Plauger","source":"The Elements of Programming Style, 2nd ed. (1978)"}},{"type":"heading","attrs":{"level":2,"id":"when-to-use-it-and-when-to-be-careful"},"content":[{"type":"text","text":"When to use it and when to be careful"}]},{"type":"prosCons","attrs":{"pros":["always as the default direction: start with the simplest solution that passes the tests","in code review – ask \"what would break if we deleted this?\"","when a business rule fits in a few sentences – let the code fit in them too","in code read by many people: internal libraries, modules on team boundaries"],"cons":["when \"simplicity\" means skipping requirements: money, time zones, security","when the problem really is complex (e.g. a price list with hundreds of rules edited by the sales team) – then the structure is essential complexity","as an argument against every abstraction – a third copy of the same logic is complexity too","as an excuse for \"clever\" shortcuts: shorter code is not always simpler"],"prosTitle":"When to apply","consTitle":"When to be careful"}},{"type":"callout","attrs":{"variant":"warning","title":"A real-world mistake"},"content":[{"type":"paragraph","content":[{"type":"text","text":"A team builds a \"platform\" instead of a feature: a generic workflow engine, a home-made plugin system, YAML configuration with conditions and loops. A year later the only person who can add a new step is the engine's author – who is just changing jobs. The phenomenon even has a name: the "},{"type":"text","text":"inner-platform effect","marks":[{"type":"italic"}]},{"type":"text","text":". If your configuration has conditions, loops and variables, it is a programming language – just without a debugger, types or tests."}]}]},{"type":"heading","attrs":{"level":2,"id":"in-practice-tools-and-code-review"},"content":[{"type":"text","text":"In practice: tools and code review"}]},{"type":"table","content":[{"type":"tableRow","content":[{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Ecosystem"}]}]},{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Tool"}]}]},{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"What it gives you"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":".NET"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"rule CA1502 from the .NET analyzers, code metrics in Visual Studio"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"method cyclomatic complexity, maintainability index"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Java"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Checkstyle "},{"type":"text","text":"CyclomaticComplexity","marks":[{"type":"code"}]},{"type":"text","text":", PMD, SonarQube"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"complexity thresholds in CI, cognitive complexity"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"TypeScript / JS"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"ESLint: the "},{"type":"text","text":"complexity","marks":[{"type":"code"}]},{"type":"text","text":" rule, "},{"type":"text","text":"sonarjs/cognitive-complexity","marks":[{"type":"code"}]}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"a per-function complexity limit, warnings in the editor"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Go"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"gocyclo","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"gocognit","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"cyclop","marks":[{"type":"code"}]},{"type":"text","text":" in golangci-lint"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"function and package complexity"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Python"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"radon cc","marks":[{"type":"code"}]},{"type":"text","text":", flake8 with "},{"type":"text","text":"--max-complexity","marks":[{"type":"code"}]},{"type":"text","text":" (C901), ruff "},{"type":"text","text":"C901","marks":[{"type":"code"}]}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"functions ranked A to F, a threshold in CI"}]}]}]}]},{"type":"paragraph","content":[{"type":"text","text":"Code review tips:"}]},{"type":"bulletList","content":[{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Ask what problem an abstraction solves "},{"type":"text","text":"today","marks":[{"type":"bold"}]},{"type":"text","text":" – not whether it might come in handy some day."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Ask for a usage example. An abstraction with a single client can usually be inlined."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Treat tool thresholds as a conversation starter, not a verdict. A "},{"type":"text","text":"switch","marks":[{"type":"code"}]},{"type":"text","text":" with twelve one-line cases can be simpler than twelve classes."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Look at names: "},{"type":"text","text":"GenericProcessorFactoryManager","marks":[{"type":"code"}]},{"type":"text","text":" says more about the architecture than about the problem."}]}]}]},{"type":"resourceRef","attrs":{"resourceId":"6b0857a33c96f2d34d0b3208"}},{"type":"heading","attrs":{"level":2,"id":"related-principles"},"content":[{"type":"text","text":"Related principles"}]},{"type":"paragraph","content":[{"type":"text","text":"KISS rarely works alone. "},{"type":"text","text":"YAGNI","marks":[{"type":"link","attrs":{"href":"/en/topics/yagni"}}]},{"type":"text","text":" tells you what not to build now – and is the most effective way to stay simple. "},{"type":"text","text":"DRY","marks":[{"type":"link","attrs":{"href":"/en/topics/dry"}}]},{"type":"text","text":" can pull against KISS: removing duplication adds an abstraction, and a wrong abstraction is accidental complexity. "},{"type":"text","text":"SOLID","marks":[{"type":"link","attrs":{"href":"/en/topics/solid"}}]},{"type":"text","text":" gives you tools to organise essential complexity, but applied mechanically (an interface for every class) it becomes a source of complexity itself. Even "},{"type":"text","text":"Strategy","marks":[{"type":"link","attrs":{"href":"/en/topics/strategy"}}]},{"type":"text","text":" only makes sense when there are several variants that really change – for a single fee formula, a function is enough."}]},{"type":"linkCard","attrs":{"url":"/en/topics/yagni","title":"YAGNI","description":"Don't build features in advance – the shortest road to simple code","kind":"topic","ref":"yagni"}},{"type":"linkCard","attrs":{"url":"/en/topics/dry","title":"DRY","description":"One source of knowledge – and when duplication is cheaper than an abstraction","kind":"topic","ref":"dry"}},{"type":"linkCard","attrs":{"url":"/en/topics/solid","title":"SOLID","description":"Five principles for organising the complexity you actually need","kind":"topic","ref":"solid"}},{"type":"heading","attrs":{"level":2,"id":"test-yourself"},"content":[{"type":"text","text":"Test yourself"}]},{"type":"quiz","attrs":{"question":"Which part of the delivery module is essential complexity?","multiple":false,"options":[{"text":"The rule priorities in the engine","correct":false,"explanation":"That is an implementation decision – the order can simply be the order of the conditions."},{"text":"Rounding started kilometres up","correct":true,"explanation":"Yes. The terms of service require it – without it the customer would pay 9.40 zł instead of 11 zł."},{"text":"The `string → object` dictionary passed to the rules","correct":false,"explanation":"That is accidental complexity: it switches the compiler off and moves errors to runtime."},{"text":"The `IFeeRule` interface","correct":false,"explanation":"An interface for three rules that nobody swaps independently is accidental complexity too."}]}},{"type":"details","content":[{"type":"detailsSummary","content":[{"type":"text","text":"Interview question: what is the difference between simple and easy code?"}]},{"type":"detailsContent","content":[{"type":"paragraph","content":[{"type":"text","text":"Rich Hickey popularised the distinction in his talk "},{"type":"text","text":"Simple Made Easy","marks":[{"type":"italic"}]},{"type":"text","text":" (2011). "},{"type":"text","text":"Simple","marks":[{"type":"bold"}]},{"type":"text","text":" is an objective property: few intertwined parts, each doing one thing and understandable on its own. "},{"type":"text","text":"Easy","marks":[{"type":"bold"}]},{"type":"text","text":" is subjective: close to what we already know – a favourite framework, a ready-made generator, a copy from the previous project. An easy solution can be complex (an ORM with magic that hides the queries), while a simple one can be harder at first (passing dependencies explicitly instead of using global state). A good answer gives an example from your own project and notes that simplicity pays off during maintenance, while ease pays off when you first write the code."}]}]}]}]},"toc":[{"id":"where-kiss-comes-from","text":"Where KISS comes from","level":2,"locked":false},{"id":"the-problem-a-rule-engine-for-three-sentences","text":"The problem: a rule engine for three sentences","level":2,"locked":false},{"id":"refactoring-from-clever-to-simple","text":"Refactoring: from clever to simple","level":2,"locked":false},{"id":"how-to-measure-complexity","text":"How to measure complexity","level":2,"locked":false},{"id":"simple-not-simplistic","text":"Simple, not simplistic","level":2,"locked":false},{"id":"signs-of-over-engineering","text":"Signs of over-engineering","level":2,"locked":false},{"id":"when-to-use-it-and-when-to-be-careful","text":"When to use it and when to be careful","level":2,"locked":false},{"id":"in-practice-tools-and-code-review","text":"In practice: tools and code review","level":2,"locked":false},{"id":"related-principles","text":"Related principles","level":2,"locked":false},{"id":"test-yourself","text":"Test yourself","level":2,"locked":false}],"locked":false,"paywall":null,"previewRatio":0.3,"totalBlocks":49,"visibleBlocks":49,"resources":[{"id":"6b0857a33c96f2d34d0b3208","type":"video","provider":"youtube","url":"https://www.youtube.com/watch?v=SxdOUGdseq4","embedUrl":"https://www.youtube-nocookie.com/embed/SxdOUGdseq4","title":"\"Simple Made Easy\" - Rich Hickey (2011)","description":"","author":"Strange Loop Conference","thumbnailUrl":"https://i.ytimg.com/vi/SxdOUGdseq4/hqdefault.jpg","durationSec":null,"lang":"en","topics":["kiss"],"techs":["general"],"tags":[],"price":"free","featured":true,"featuredOrder":1,"packageName":null,"source":"seed","publishedAt":null,"popularity":0,"verifiedAt":"2026-11-26T00:00:00.000Z","curated":true,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:00:35.916Z","updatedAt":"2026-11-26T16:00:35.916Z"},{"id":"6b0857c33c96f2d34d0b4678","type":"book","provider":"openlibrary","url":"https://openlibrary.org/works/OL21221785W","embedUrl":null,"title":"A Philosophy of Software Design","description":"","author":"John K. Ousterhout","thumbnailUrl":"https://covers.openlibrary.org/b/id/10352230-L.jpg","durationSec":null,"lang":"en","topics":[],"techs":["general"],"tags":["book"],"price":"paid","featured":false,"featuredOrder":0,"packageName":null,"source":"openlibrary","publishedAt":"2018-01-01T00:00:00.000Z","popularity":56,"verifiedAt":"2026-11-26T11:00:08.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:01:04.995Z","updatedAt":"2026-11-26T16:01:04.995Z"},{"id":"6b0857b43c96f2d34d0b3808","type":"article","provider":"web","url":"https://danluu.com/simple-architectures","embedUrl":null,"title":"In Defense of Simple Architectures (2022)","description":"","author":"danluu.com","thumbnailUrl":null,"durationSec":null,"lang":"en","topics":[],"techs":["general"],"tags":["hacker-news"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"hn","publishedAt":"2024-02-20T11:50:34.000Z","popularity":80,"verifiedAt":"2026-11-26T11:19:38.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:00:51.221Z","updatedAt":"2026-11-26T16:00:51.221Z"},{"id":"6b0857bd3c96f2d34d0b4085","type":"podcast","provider":"apple-podcasts","url":"https://podcasts.apple.com/us/podcast/the-s-in-kiss-embracing-simplicity-with-guilherme/id1478997569?i=1000670736207","embedUrl":"https://embed.podcasts.apple.com/us/podcast/id1478997569?i=1000670736207","title":"The S in KISS…..Embracing simplicity with Guilherme Ferreira - .NET 198","description":"Today we look at using simplicity both in your code at work an in your life and why the two are intertwined. How to bring Occam’s Razor to work to help keep projects from getting out of hand. A better way to look at dead time and why its necessary to allow your mind to rest. Links OMNIA-Low-Code…","author":"Adventures in .NET","thumbnailUrl":"https://is1-ssl.mzstatic.com/image/thumb/Podcasts221/v4/5d/d5/d6/5dd5d6e0-7ac9-02a0-8ed5-552b1799162e/mza_12244077636776526340.jpg/600x600bb.jpg","durationSec":3759,"lang":"en","topics":["kiss"],"techs":["dotnet"],"tags":["podcast","devops"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"itunes","publishedAt":"2024-09-24T10:00:00.000Z","popularity":43,"verifiedAt":"2026-11-26T11:07:22.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:00:59.965Z","updatedAt":"2026-11-26T16:00:59.965Z"},{"id":"6b0857be3c96f2d34d0b41e8","type":"article","provider":"web","url":"https://martinfowler.com/bliki/BeckDesignRules.html","embedUrl":null,"title":"bliki: Beck Design Rules","description":"When developing Extreme Programming in the 90's, Kent Beck developed four rules of simple design: Passes the tests, reveals intention, no duplication, and fewest elements.","author":"Martin Fowler","thumbnailUrl":"https://martinfowler.com/bliki/images/beckDesignRules/sketch.png","durationSec":null,"lang":"en","topics":[],"techs":["general"],"tags":["martin-fowler","testing"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"manual","publishedAt":null,"popularity":75,"verifiedAt":"2026-11-26T11:07:17.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:00:59.965Z","updatedAt":"2026-11-26T16:00:59.965Z"}],"challenges":[],"attachments":[],"hasCode":true,"repoUrl":null,"series":[{"slug":"design-principles","title":"Design principles","items":[{"slug":"kiss","title":"KISS: the simplest working solution usually wins","current":true},{"slug":"dry","title":"DRY: one piece of knowledge, one place – and when duplication is cheaper","current":false},{"slug":"yagni","title":"YAGNI: don't build ahead – what a feature nobody ordered really costs","current":false},{"slug":"law-of-demeter","title":"The Law of Demeter: talk only to your friends","current":false},{"slug":"solid","title":"SOLID: five object-oriented design principles without the myths","current":false}]}],"prev":null,"next":{"slug":"dry","title":"DRY: one piece of knowledge, one place – and when duplication is cheaper"},"featured":false,"authorCard":{"id":"6b08bd2e80884893657cc8cf","name":"Redakcja Art of Devs","avatar":null,"handle":"redakcja","headline":"Wzorce projektowe · Architektura · AI i LLM","community":false,"reputation":{"points":3900,"level":{"key":"mentor","label":"Mentor"}},"articles":104,"skills":[{"key":"typescript","title":"TypeScript","level":5,"levelLabel":"Authority","articles":90},{"key":"dotnet","title":".NET","level":5,"levelLabel":"Authority","articles":61},{"key":"python","title":"Python","level":5,"levelLabel":"Authority","articles":59},{"key":"java","title":"Java","level":5,"levelLabel":"Authority","articles":46}]}}