Hi folks. I was wondering if anyone has developed ...
# compose
s
Hi folks. I was wondering if anyone has developed any helpful naming conventions for list items in Compose? - I am working on an app which displays a list of sicknesses. I don't want to call the composable SicknessItem, because that is what the data model is called. I don't want to call it SicknessItemView, as that has connotations of the old View system in Android. SicknessItemComposable feels a little clunky. Any ideas?
c
I've used
FooItemView
,
FooRow
(but this naming collapsed when we had to change it to a grid view in some cases),
FooCell
(reminiscent of iOS UITableViewCell). In the end I settled on
FooItem
because for the UI model I suffix State (
FooItemState
).
👍 2
a
While appending
State
for UI model is generally what's expected in Compose land, for other models, e.g. for JSON representation, things can change. In our case having
Item
in the JSON model class added no contextual advantage.
FoodItem
and
Food
convey the same thing — they're a data representation of food. We don't need to know where & how this data would be used. It's only on the UI side where it makes sense to use
Item
, because then it's immediately obvious that it's meant to be within some form of a list/grid. Plus, in Room our table name has always been
food
, so removing
Item
also allowed us to remove
@Entity(tableName = "food")
.