Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
fullstack ruleP1universalStack: universal
performancefetchingoptimizationredundancy
Skip a dependency fetch when its result is already available
Before firing a request whose only purpose is to derive inputs you already have (e.g. from query params), short-circuit and reuse them to avoid an unnecessary round trip.
PR: hegnar-forum-web · org-mining-2026-06Created: Jun 17, 2026
Bad example
Old codets
| 1 | const dates = await getDates(id); |
| 2 | const data = await getData(id, dates[0], dates[1]); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codets
| 1 | if (fromParam && toParam) { |
| 2 | return getData(id, fromParam, toParam); // skip getDates |
| 3 | } |
| 4 | const dates = await getDates(id); |
| 5 | return getData(id, dates[0], dates[1]); |
Explanation (EN)
Objašnjenje (HR)