Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PowerShell receive vs. get verbs

I've seen quite a few discussions on which verbs to use in your own PowerShell functions, but I haven't seen a clarification on using Receive vs. Get. They mean roughly the same thing to me, but Receive is supposed to be used specifically in situations involving communications (just type Get-Verb to see this). Get, however, is in the Common group, so I'm really not sure which one to use.

I have a function that basically wraps a RESTful API and gets data from it (I use parameter sets for the different methods of the service). Right now the function is called Get-FooData. However, I'm thinking that I should possibly rename it to Receive-FooData since it is doing some communication.

I think I'm being too literal here in wanting to use Receive. My personal feeling is that Get sounds better, but I think that's just because I'm used to using it. What are your thoughts?

like image 741
Christopher Broome Avatar asked Nov 29 '10 21:11

Christopher Broome


2 Answers

Although I'm proficient at PowerShell at only the amateur level, for me, "get" implies a much more forceful and in-charge type of code. Meaning my code is going to initiate the action, and the other software will humbly respond to my request.

"Receive" sounds more docile, meaning the other software is really in charge. So I might use Receive if the other software was for example putting out temperatures once a minute. I'm going to receive the data, but the other software is doing its thing even if I wasn't there to receive it.

"Get" is shorter and most of the time I like to feel like my code is in charge. Go with Get.

like image 151
Knox Avatar answered Sep 27 '22 22:09

Knox


Use the noun to decide. If your noun is the object that is being retrieved then use "GET". If the noun is the mechanism by which you retrieve something, then use "RECEIVE".

e.g.

GET-BOOK -via REST

RECEIVE-REST -object book

like image 28
Jeffrey Snover - MSFT Avatar answered Sep 28 '22 00:09

Jeffrey Snover - MSFT