ctripcorp / mmkv-kotlin

A Kotlin Multiplatform porting for MMKV.
Apache License 2.0
131 stars 11 forks source link

Why did you change the standard getters/setters? #29

Open realcbnewham opened 6 months ago

realcbnewham commented 6 months ago

I'd put this in discussion but there doesn't seem to be one - and it is somewhat of a feature request.

This library is excellent apart from the fact that you have renamed the functions. Why does it have to be "set" and "takeXXX" when it should be using the original put and get names (and set and take are not opposites in English)? This could been a very convenient drop-in but I've spent a lot of time renaming all of the getters/setters from my Android native code in order to use this in a KMP version. It's a real PITA and I do not see why it was necessary.

Please consider using the original MMKV function signatures and names as aliases for your function names.

9468305 commented 6 months ago

In MMKV original version, different languages have different function signatures.
Java: "encode" and "decode", "getXXX" and "putXXX".
Objective-C: "getXXX" and "setXXX".
It need to be consistent in MMKV-Kotlin, but "takeXXX" is not the best name indeed.

qiaoyuang commented 6 months ago

Hi, originally, during the development process, when I took the API names same with the MMKV Java version, that's very confusing, and very easy to make mistakes. So, I changed these names. Actually, the takeXxx APIs are just like the APIs in JSONObject. Now, I would consider adding a set of new APIs, make them more common, and easy to understand. Thanks for your issue.