4 ms·
I guess a verb phrase comes up naturally when you are eager to implement a new function and think of all the steps required to calculate the result. However, a
by augustk 6y ago
I guess a verb phrase comes up naturally when you are eager to implement a new function and think of all the steps required to calculate the result. However, a noun phrase is a more proper abstraction since the implementation may change to simply return a cached value. (see also the Uniform Access Principle).
Anyway, here is my naming strategy:
1. Boolean pure function
Use an adjective phrase where the adjective is the last word, for instance UrlValid or DefinitionFound.
2. Non-boolean pure function
Use a noun phrase where the noun is the last word, for instance CurrentDefinition or DefinitionUrl.
3. Non-pure "function"
Use a verb phrase where the verb is the first word, for instance PrintError or ReadInput.