Style question: When you have a file with a primary "for use by others" composable, and it is made up of sub pieces (composables), do you tend to put the children above and the parent at the bottom to compose all of the pieces together? Or the other way around? Parent at top, with children below? The C programmer in me wants to do the former, but I'm curious if there's a common idiom/convention?
10/27/2023, 3:47 PM
I do the second, adding at the end of the file is usually better for git diff than adding at the top. In c you don't have that luxury, you have to define first whatever you use, he used to it.
10/27/2023, 3:56 PM
If you're thinking of them as parent & child, then it makes more sense for parent to be defined first.
If you instead see them as function depending on another function, the C-era arrangement can take over mentally.
I wish this Java code style thingy was available for Kotlin as well
Also, at least for composables, its better if the "main" composable is defined right at the top because that's what most clients (read: callers) will see. They shouldn't care about internal child implementations.
10/27/2023, 4:40 PM
Do you put Previews at top or bottom?
10/28/2023, 3:28 AM
Previews at the bottom, but I'm conflicted if it should be below private vals or above them