Are extension functions on `LazyListScope` expecte...
# compose
e
Are extension functions on
LazyListScope
expected to be UpperCamelCase? I know they aren't composable functions, but they wrap them in a lot of cases (i.e. they hide calls to
item
or
items
inside of them) and so it looks weird in a composable function to see a function call that looks like it will emit UI, but named in lowerCamelCase.
t
I've had this observation as well.
l
Functions are generally named in lowerCamelCase. Only constructor-like functions (
Job()
,
SerializersModule {}
) and @Composable functions that emit UI are named UpperCamelCase. If it itself isn't @Composable, it should be named in lower, and if it is @Composable but doesn't emit UI, it's also named lower.
e
I understand but these feel like they emit UI (even though they don't directly)
l
Yeah it is whether direct or not that decides its case, in order to tell whether something can be called in a @Composable context. Like, "yeah it's all upper, then why can't I call
Box
inside
LazyListScope
?".
e
All true, it just feels like a gray area, and the code looks weird to me
For example
reportItems
looks out of place here.
Copy code
Box {
  LazyColumn {
    reportItems()
  }
}

fun LazyListScope.reportItems() {
  items(...) {
    Card(...)
  }
}
d
I did the same thing here. And I kind of regret it lol. I can not explain why exactly, but to me it just… “smells funny” Mind you
stickyHeader
is basically the same idea, and it is lowercase. Just like
item {…}
and
items(…) {…}
.
I think the 3 above mentioned items are fine because they are generic enough to apply to all
LazyListScope
but
.reportItems
feels like its specific to a particular UI that shows `Report`s. maybe it should be
internal
or
private
?
e
Yeah it would be private, I just threw something together quickly.
d
If
private
is the case then that seems totally fine.