Hi everyone! I have a question about prefixing (us...
# announcements
Hi everyone! I have a question about prefixing (usually private) variables with
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)
Copy code
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 😄 :
Copy code
private val someState = MutableStateFlow(5) 
	public get(): StateFlow<Int> = field
@ephemient thanks! 🙂
the topic is slowly collecting votes 😄


according to the video it is very straightforward, sadly it didn't happen yet 😄