Is there a good naming convention for this? ```fun...
# codingconventions
m
Is there a good naming convention for this?
Copy code
fun doSomething()
suspend fun doSomethingSuspending()
e
Copy code
suspend fun doSomething()
fun doSomethingBlocking()
👍 13
Rationale:
Blocking
variant is more dangerous and, what's worse, can be called from anywhere (by mistake), so it must have a longer name
7
m
Ok and what if i have something like this
Copy code
// fire and forget
fun dispatch(action: Action)
// dispatches the action and suspends until consumed
suspend fun dispatchSuspend(action: Action)
As an alternative i could do this?
Copy code
fun dispatch(action: Action): Deferred<Unit>
e
That's a totally different story. In this case use different verbs or invent some other way to differentiate between them. In the latter case cal the function
dispatchAsync
to highlight the fact that it only starts the action, but does not wait for its completion in any way.
m
Ok thanks.