Naming question for Compose: we all know that Comp...
# naming
r
Naming question for Compose: we all know that Components should be small, reusable and single-purpose and Screens should be the top-level entry point which mostly just sticks Components together. But do we have a convention in-between for sub-screens which might just be a few Components and are related enough to extract to a (private) function but neither full Screens nor reusable. Example would be an Empty state for a List which is just Image + a few Texts. My first thought was that this would also be a Screen but not sure how strictly we should interpret that definition of Screen (can't find any docs from Google that clarify this)
c
What names are you considering? Why not name it just after what it does?
r
It really doesn't do anything though. Here's a simplified example to show what I mean
Copy code
@Composable
fun MyBasketScreen(items: List<BasketItem>) {
  if (items.isEmpty()) {
    WhatToCallThis()
  else {
    LazyColumn(items) {
       ...
    }
  }
}

@Composable
private fun WhatToCallThis() {
  Column {
    Image(myEmptyImage)
    Text("No items in basket")
    Text("Click the button to add items to basket")
  }
}
All the ideas I had are either too generic or too implementation-specific • MyBasketEmptyScreen • MyBasketEmptyView • MyBasketEmptyText • MyBasketEmptyMessage • MyBasketEmptyContent • MyBasketEmptyDescription • MyBasketEmptyLayout • MyBasketEmptyComponentGroup
Maybe I'm thinking about the problem the wrong way 🤔
c
what about…
MyBasketEmpty
?
other than that,
MyBasketEmptyContent
seems clear to me
b
or even just
EmptyContent
since it's private
1
r
Yeah, not really sure about not having any Suffix. Fine with Content since it’s used quite a bit in Compose API even though it’s fairly meaningless
Thanks all