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).
backend ruleP1universalStack: TypeScript
architecturedependency-injectionseparation-of-concerns
Confine a cross-cutting dependency to the layer that owns it
A dependency like a cache model should live in the base/dedicated class that uses it, not be threaded through unrelated subclasses and their constructors.
PR: hegnar-ws · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | class InvestorwebDataProvider { |
| 2 | constructor(private model: ICacheModel) {} // not its concern |
| 3 | } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | class InvestorwebDataProvider extends CachedDataProvider { |
| 2 | // caching dependency lives in CachedDataProvider |
| 3 | } |
Explanation (EN)
Objašnjenje (HR)