Naming The Async Function - Part 3

May 26, 2024

Previously, I grouped async tasks inside a task object. This helps in keeping the function name short and easy to search, but I ended up rarely using it.

The idea seems good enough, it looks clean, but it adds up to the complexity of the writing now that I have to selectively group the async functions.

A Better Approach

So I'm back at square one but with a better idea. Instead of using "Task-" prefix, which is adapted from C# by the way, it's better to use "-Async" postfix :

js
// previous writing
async function TaskRefreshList() {
  // ...
}


// updated writing
async function RefreshListAsync() {
  // ...
}

This way, it's easy to search a function name by the first letter, and I still can tell an async function at first glance.

Improving from Here

I've tested yet a better way to name an async function, i.e. to use an even shorter postfix.

Continue to part 4 (final).

Comments

Thank You

for your visit