I can see how the choice is architecture dependent. If you can write something like:
Display(promotedPosts())
Display(recentPosts())
having the function be written without a verb makes sense.
If you have a multi-tier architecture where you want to cache things locally, the code might have to be:
PostList = getPromotedPosts()
Append(PostList, getRecentPosts())
ShowOnScreen(PostList)
I would say the distinction is that if a function takes a long time to go look at a database and do some post-processing, we don’t want to run around using it like a variable. Especially if the database might change between one use of the data and the next, but we want to keep the results the same. That way, the code can be:
PromotedPosts = getPromotedPosts()
Display(PromotedPosts)
…user clicks a button
Email(PromotedPosts) //this sends the displayed posts, not whatever the promoted one happen to be at that moment
Yes, if it “takes a long time to go look at a database and do some post-processing”, that would be a case where (as I put it) “there is a retrieval operation involved and it might be expensive”, and then we might want a name that makes it easier to guess that it might be expensive.
I can see how the choice is architecture dependent. If you can write something like:
Display(promotedPosts()) Display(recentPosts())
having the function be written without a verb makes sense. If you have a multi-tier architecture where you want to cache things locally, the code might have to be: PostList = getPromotedPosts() Append(PostList, getRecentPosts()) ShowOnScreen(PostList)
I would say the distinction is that if a function takes a long time to go look at a database and do some post-processing, we don’t want to run around using it like a variable. Especially if the database might change between one use of the data and the next, but we want to keep the results the same. That way, the code can be: PromotedPosts = getPromotedPosts() Display(PromotedPosts) …user clicks a button Email(PromotedPosts) //this sends the displayed posts, not whatever the promoted one happen to be at that moment
Yes, if it “takes a long time to go look at a database and do some post-processing”, that would be a case where (as I put it) “there is a retrieval operation involved and it might be expensive”, and then we might want a name that makes it easier to guess that it might be expensive.