Joost Klitsie
05/07/2021, 6:52 AM_
and then having a duplicate field with the public type. Can anyone explain to me why this is beneficial? I see the text here: https://kotlinlang.org/docs/coding-conventions.html#names-for-backing-properties
I personally dislike the idea of having prefixes to indicate visibility, it doesn't make the code easier to read and it feels very much like a workaround. Public API anyway to me sounds like interfaces, so usually I prefer to hide it behind an interface, (but of course the field is then easily accessible by casting to the implementation class and this pattern desires guidelines that all developers on a project adhere to)
interface Whatever { val someState: StateFlow<Int> }
class WhateverImplementation: Whatever { override val someState = MutableStateFlow(5) }
Are there any plans to be able somehow to change the type based on private/public access? Following code is probably an impossible idea, but you get the point 😄 :
private val someState = MutableStateFlow(5)
public get(): StateFlow<Int> = field
ephemient
05/07/2021, 6:54 AMJoost Klitsie
05/07/2021, 6:56 AMJoost Klitsie
05/07/2021, 6:57 AM