SafeArgs and View Binding properties visibility

This question could be applied to many other cases.

In a android fragment class implemented with Kotlin, it’s common to see this using View Binding and SafeArgs:

class MyFragment: Fragment(){
    var _binding: MyFragmentBinding? = null
    val binding get() = _binding!!
    val args: MyFragmentArgs by navArgs()
    val data = args.data 
[...]

Why are not private these properties? It’s not a bad pattern to expose my properties to another classes if it’s not needed?

Leave a Comment