Objects with Composables!??
In a lot of my testing and examples, I tend to wrap code in objects. You won't see this in production so it may come as a bit of a shock. I'd like to briefly explain why I do this. I can then link this to all my tutorials so people don't get too confused (thank you if you are coming here from one of those). There are three main advantages to using objects: It's better , safer , and faster ! I realize I'll need to justify those three. This should be a friendly format for people of all experience levels, but there may be code that newer programmers don't understand. That should not affect the message. All final GitHub Gists are linked at the end of this post if you find those easier to read. Standard Practice Throughout most projection apps, everything is structured like this: Standard1.kt /** * Internal can be accessed within this package (whyuseobjects) * If we make a new module, it would not be able to access this */ @Composable internal fun TitleBar (title:...