In cases where we have a function that doesn't acc...
# codingconventions
j
In cases where we have a function that doesn't accept any parameters but returns a value, should we actually be using a
val
? 1️⃣
Copy code
interface A {
  val flowOfSomething: Flow<Object>
  fun flowOfAnotherThing(parameter: Parameter) : Flow<Object> // This makes sense as a function as it needs a parameter.
}
2️⃣
Copy code
interface A {
  fun flowOfSomething(): Flow<Object>
  fun flowOfAnotherThing(parameter: Parameter) : Flow<Object>
}
Thoughts?
m
yeah I think option 1. If you don’t need a function it seems overkill. I’m wondering if you should even separate the flow from that second function. Could you have both flows as val’s and observe them separately from the function that takes the param?
i.e. the function can update the flow which is being observed already.
j
Only use a val if you're sure you want every invocation to return the same result. I personally would not make an interface that prescriptive
In most circumstances