InsanusMokrassar / ktgbotapi

Type-safe library for work with Telegram Bot API
https://docs.inmo.dev/tgbotapi/index.html
Apache License 2.0
342 stars 29 forks source link

Enable API mode explicitly in ktgbotapi.api module #874

Closed bpavuk closed 1 month ago

bpavuk commented 1 month ago

This is recommended for modules whose only purpose is to expose the inner functionality to outside code. This mode forces some best practices for API design, like explicitly specifying visibility and types for public functions

InsanusMokrassar commented 1 month ago

This is recommended for modules whose only purpose is to expose the inner functionality to outside code. This mode forces some best practices for API design, like explicitly specifying visibility and types for public functions

Why API should be explicit?

bpavuk commented 1 month ago

Explicit visibility and return type specification will ease future efforts with documentation a lot. Due to type inference, documentation updates will require far more effort. IDE will update the types on itself if they ever change their name (like it was with TelegramMedia -> TelegramFreeMedia. Also, this will make you think twice about the API design.