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 ruleP2universalStack: typescript
dryoopinheritancerefactor
Pull shared methods up into the base class to eliminate duplication
When subclasses repeat the same method, move it to the base class (abstract or concrete) rather than copying it into each subclass.
PR: frontpage-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | class A extends Base { renderPage() { /* same body */ } } |
| 2 | class B extends Base { renderPage() { /* same body */ } } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | abstract class Base { renderPage() { /* shared body */ } } |
| 2 | class A extends Base {} |
| 3 | class B extends Base {} |
Explanation (EN)
Objašnjenje (HR)