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.
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!
https://vanillawebdev.blogspot.com/2024/05/naming-the-async-function-part-4.html https://www.blogger.com/blog/post/edit/8166404610182826392/2324828694948532513 https://www.blogger.com/blog/page/edit/8166404610182826392/2324828694948532513Naming The Async Function - Part 4 (Final)
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.
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
Post a Comment