mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2026-06-30 23:25:16 +00:00
Add HELPERS rule preferring members over when-dispatch extensions
Document that a property/method which can live on an interface/class must be declared there and overridden per implementation, instead of a common extension that dispatches with a when over every subtype; shared logic goes into a companion-object function or an internal top-level helper. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -48,3 +48,7 @@ Each section can be ommited if there are no any changes in the section. In case
|
||||
* `Core`:
|
||||
* (`Guest mode`) // change data
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
When a property (or method) can be declared on an interface/class and implemented by each inheritor - it MUST be declared there and overridden per implementation. DO NOT implement such behaviour as a common extension property/function that dispatches with a `when (this)` over every subtype: those branches silently drift out of sync when new subtypes are added and are not part of the type contract. If a part of the implementation is reused across several inheritors, keep that part in a shared helper (a companion-object function of the owner, or an `internal` top-level function for logic shared between different types) and let the overrides reuse it.
|
||||
|
||||
Reference in New Issue
Block a user