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 ruleP2universalStack: TypeScript
encapsulationoopapi-design
Expose a focused getter/method rather than handing out the whole entity
To let callers read one derived value, expose a getter or method for it; don't leak the underlying entity object so the deriving logic stays inside the owning class.
PR: hegnar-ws · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | interface IWebcast { |
| 2 | drPublishEntity: DrPublish.IWebcastEntity; // caller digs out the id itself |
| 3 | } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | interface IWebcast { |
| 2 | get webcastId(): string; // logic for deriving the id stays in the class |
| 3 | } |
Explanation (EN)
Objašnjenje (HR)