Naming The Async Function - Part 4 (Final)

May 26, 2024

Previously, I started using "-Async" postfix to name an async function. This turns out to be a better approach than the predecessor, but not for long.

After a while, it felt cumbersome to type in, especially now that I've been working with dozens of async functions lately. So here's a better approach: to use underscore "_" postfix as a replacement for "-Async".

Underscore Postfix

I don't think anyone would be using underscore postfix to name anything. The reason might be because it simply holds no meaning and there's just no reason to. So this should be fine for a naming convention.

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


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

It still kept the previous traits: 

  • easy to search by the first letter,
  • and distinguishable from synchronous function at first glance. 
Even better now, it takes less space and less character to type in.

End of Series

In the world of vanilla JS, I don't think I'll find any better approach than this in naming an async function. So I'll go ahead and mark this as the final part of the series. 

See ya in another post!

Comments

Thank You

for your visit