Replies: 1 comment
-
|
Added in https://steamcommunity.com/games/CSGO/announcements/detail/498333631688738078 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
For many of the functions exposed by the API that accept more than two parameters, it would be more beneficial to instead pass an object where the arguments are keyed.
This would eliminate any concern about the order of the arguments passed in, provide API stability by preventing the addition / removal of method parameters from breaking existing code, and greatly improve overall code readability and extensibility - especially so in the case of functions where several of its parameters share the same type.
Example 1
Current - multiple args (far less readable at a glance, order of args is crucial):
Proposed - single object (immediately clear what each value represents, extensible, order of args is irrevelant):
Example 2
This proposal also extends to methods that accept a callback as a parameter, where it would be more useful if those callbacks were instead passed an object, as this would allow you to destructure that object and access specific properties, rather than needing to leave unused parameters, e.g:
Current:
Proposed:
Example where this is already implemented:
Beta Was this translation helpful? Give feedback.
All reactions