# Kotlin Coroutine Confidence: Change function name, maybe (pg 182)

**URL:** <https://forum.devtalk.com/t/kotlin-coroutine-confidence-change-function-name-maybe-pg-182/197038>\
**Category:** PragProg Customers\
**Tags:** suggestion, book-kotlin-coroutine-confidence\
**Created:** [29 April 2025 19:49 UTC](https://forum.devtalk.com/t/kotlin-coroutine-confidence-change-function-name-maybe-pg-182/197038 "2025-04-29T19:49:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Javaru](https://forum.devtalk.com/user_avatar/forum.devtalk.com/javaru/32/7352_2.png) [@Javaru](https://forum.devtalk.com/u/Javaru)\
**Post date:** [29 April 2025 19:49 UTC](https://forum.devtalk.com/t/kotlin-coroutine-confidence-change-function-name-maybe-pg-182/197038/1 "2025-04-29T19:49:28Z")

</div>

For `pets/v2/src/main/kotlin/com/example/pets/Helpers.kt` (and in subsequent versions), I think it might be helpful to change the `block` parameter name to something else.

```auto
suspend fun createWindow(
  title: String,
  block: suspend CoroutineScope.(JFrame) -> Unit
): Unit = withContext(Dispatchers.Main) {

```

Understandably in Kotlin `block` is a common name for a function type parameter that is block of code to be executed (such as in the case of the Kotlin scope functions). But here I think the name can cause confusion due to the ambiguity with **blocking** code in the context of discussing Coroutines. Especially given it’s signature is `block: suspend...`. In my case I saw its use before I saw its definition and started to think there was a new Coroutine `block()` function we were about to learn about. Perhaps `codeBlock` might be a better name , or `create`? (`create` makes more sense at the point its called in my humble opinion.)

Also, unless I am mistaken, this is the first time we have seen the `suspend` key word as part of a function type parameter definition. So a couple of sentences highlighting that fact might be helpful. Like “hey did you notice we can define function type parameters as suspending functions?”

#book-kotlin-coroutine-confidence version B3

---

<div class="post-metadata">

**Author:** ![sam-cooper](https://forum.devtalk.com/user_avatar/forum.devtalk.com/sam-cooper/32/7446_2.png) [@sam-cooper](https://forum.devtalk.com/u/sam-cooper)\
**Post date:** [30 April 2025 07:32 UTC](https://forum.devtalk.com/t/kotlin-coroutine-confidence-change-function-name-maybe-pg-182/197038/2 "2025-04-30T07:32:50Z")

</div>

I hadn’t considered that writing _block_ right next to _suspend_ could be confusing! It’s an interesting and very valid point. I think it’s very important to reduce opportunities for that kind of confusion when presenting code examples, so I’ll certainly consider changing this one. I’m tempted to go with something like `builder` or `windowBuilder`—I’ll give it some thought.

I also appreciate you pointing out that this might be the first time we’ve used a suspending lambda function as an argument to another function. I glossed over this code pretty quickly, since it’s mostly just there to simplify and enable the following code examples, but I agree, a quick note about that might be useful. Suspending lambdas are an important feature, after all.

Thank you for the feedback!

---

<div class="post-metadata">

**Author:** ![Javaru](https://forum.devtalk.com/user_avatar/forum.devtalk.com/javaru/32/7352_2.png) [@Javaru](https://forum.devtalk.com/u/Javaru)\
**Post date:** [30 April 2025 14:05 UTC](https://forum.devtalk.com/t/kotlin-coroutine-confidence-change-function-name-maybe-pg-182/197038/3 "2025-04-30T14:05:12Z")

</div>

> [@sam-cooper](#):
>
> I’m tempted to go with something like `builder` or `windowBuilder`

Either of those work well I think. 👍 As the saying goes, the hardest thing in software development is naming things.
