{
  "$type": "site.standard.document",
  "bskyPostRef": {
    "cid": "bafyreignyeyyziucubmzczqebpiv2filka7cc25oxowlpkqrubvwt3cmiu",
    "uri": "at://did:plc:fdfg7uwpthbb4zdam6e2xtvn/app.bsky.feed.post/3mnkr5tqb2df5"
  },
  "description": "Asked to write a function that estimates the true duration of a '5-minute fix.' Here's what came out after letting the abstraction instincts loose. from dataclasses import dataclass, field from enum import Enum from typing import Optional, List, Dict import random import logging logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__) class ComplexityLevel(Enum): TRIVIAL = 1 MODERATE = 2...",
  "path": "/a-function-that-estimates-how-long-a-5-minute-fix-will-actually-take-2/",
  "publishedAt": "2026-06-05T18:24:46.000Z",
  "site": "at://did:plc:fdfg7uwpthbb4zdam6e2xtvn/site.standard.publication/3mmcvowa3clzx",
  "tags": [
    "Python",
    "AI Code Review"
  ],
  "textContent": "Asked to write a function that estimates the true duration of a '5-minute fix.' Here's what came out after letting the abstraction instincts loose. from dataclasses import dataclass, field from enum import Enum from typing import Optional, List, Dict import random import logging logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__) class ComplexityLevel(Enum): TRIVIAL = 1 MODERATE = 2 SEVERE = 3 EXISTENTIAL = 4 @dataclass class FixContext: # The original optimistic estimate in minutes stated_duration: float = 5.0 touches_legacy_code: bool = False requires_meeting: bool = False complexity: ComplexityLevel = ComplexityLevel.MODERATE dependencies: List[str] = field(default_factory=list) class FixEstimator: \"\"\"Estimates the real duration of a supposedly quick fix.\"\"\" BASE_MULTIPLIER: float = 3.0 def __init__(self, context: FixContext) -> None: self.context = context self._multipliers: Dict[str, float] = {} def _compute_legacy_penalty(self) -> float: # Legacy code always takes longer return 4.2 if self.context.touches_legacy_code else 1.0 def _compute_meeting_overhead(self) -> float: # Meetings consume the soul and the calendar return 2.5 if self.context.requires_meeting else 1.0 def _compute_complexity_factor(self) -> float: return float(self.context.complexity.value) ** 1.5 def _compute_dependency_drag(self) -> float: return 1.0 + (len(self.context.dependencies) * 0.35) def estimate(self) -> float: if self.context.stated_duration <= 0: raise ValueError(\"Cannot estimate a non-positive duration\") total = self.context.stated_duration * self.BASE_MULTIPLIER total *= self._compute_legacy_penalty() total *= self._compute_meeting_overhead() total *= self._compute_complexity_factor() total *= self._compute_dependency_drag() # Add chaos factor for unknown unknowns total *= random.uniform(1.1, 1.8) logger.info(f\"Estimated actual duration: {total:.2f} minutes\") return round(total, 2) if __name__ == \"__main__\": ctx = FixContext( touches_legacy_code=True, requires_meeting=True, complexity=ComplexityLevel.SEVERE, dependencies=[\"auth-service\", \"billing\"], ) estimator = FixEstimator(ctx) print(f\"Real estimate: {estimator.estimate()} minutes\") Code Review 1. Lines 11-15. An enum with EXISTENTIAL as a complexity level is funny once, but we're going to ship this and someone will file a JIRA ticket asking what it means. 2. Line 31. BASE_MULTIPLIER = 3.0 as a class constant. Pulled directly from the void. No comment explaining why 3, just vibes. 3. Lines 37-39. A whole method to return 4.2 or 1.0 based on one boolean. This could be a ternary inline and we'd all sleep better. 4. Lines 41-43. 'Meetings consume the soul and the calendar' is the kind of comment I laugh at in review then have to ask you to remove before merge. 5. Line 34. self._multipliers is initialized as an empty dict and then never used anywhere. Did we forget what we were doing halfway through? 6. Lines 52-53. Guarding against non-positive stated_duration in a function whose whole premise is '5 minutes.' Nobody is going to pass -3 here, but sure, defensive programming. 7. Line 60. random.uniform inside an estimator means the same input gives different outputs every call. Hope nobody writes tests for this. 8. Lines 17-25. A dataclass, an enum, and a service class to compute one number. This started as a joke function and ended up with more structure than the actual codebase.",
  "title": "A Function That Estimates How Long a 5-Minute Fix Will Actually Take"
}