rsocket / rsocket-kotlin

RSocket Kotlin multi-platform implementation
http://rsocket.io
Apache License 2.0
553 stars 37 forks source link

Use Paytload{} instead of buildPayload{} #278

Open SPC-code opened 1 month ago

SPC-code commented 1 month ago

Functions like buildList were frequently used at the beginning of Kotlin, but it seems like nowadays it is much better to use fake constructors instead of top-level functions. So, I suggest adding a Payload{ } builder and deprecate buildPayload without changing its desgin.

Motivation

The only motivation for this change is discoverability. If you want to create Payload, you start typing Payload without looking into documentation for function. It is not possible to do that for List in the standard library because it would be ambiguous now, but for Payload it seems to be a good solution.