DEV Community

Adam Chapman
Adam Chapman

Posted on

Naming Your Functions.. Get in the VAN!

Get in the VAN

If there's one thing I like.. it's code readability, consistency and acronyms and grammar. A convention I (possibly) came up with for naming functions makes this often brain-bending task fairly painless.

V.A.N. - Verb, Adjective, Noun

Eg:

getAngryBirds()
findLostTreasure()
removeUnwantedHair()
slayEvilDragon()
playKillerSolo()
patFriendlyDog()
decryptGovernmentDatabase()
killWhiteWalker()
Enter fullscreen mode Exit fullscreen mode

In cases where an adjective is not applicable.. I fall back to Verb, Noun.

Eg:

getBirds()
findTreasure()
removeHair()
slayDragon()
playSolo()
patDog()
decryptDatabase()
killWalker()
Enter fullscreen mode Exit fullscreen mode

Pluralisation should also be used to appropriately reflect the entity being used.

Enjoy nameNextFunction()

Top comments (0)