1

I am trying to find good names for a part of my software which I would describe as a layer. Multiple layers can lay ontop of each other and interact only with the layer above and the layer below.

Each layer can either send or receive from either above or below creating 4 function which I need to name.

With respect to the sending part, a simple name is short and easy send_up and send_down. However for the receive, the most natural word to pick seems to be receive_from_down and receive_from_up. However I don't like the 2 vs 3 word solution.

I am looking for a single word to represent receive from which makes sense in this context.

--- Edit ---

To increase clarity (Andrew Leach's comment), the reason I don't like "get" is because it's active while as "receive from" is passive. An example; if the layers are:

A
B

Assume that A is generating data from thin air. A would call send_down() which is an alias to receive_from_up() on B. B at a later date would call send_up() which is an alias to receive_from_down() on A. At no point would a layer call it's own receive_from_down(). So receive half of the problem is always initiated by a neighbor. This makes me feel that get is confusing.

To Jim: There is a hierarchy. Any layer can choose to pass a received message to the next neighbor or not. Any layer can also generate a message in either direction spontaneously.

  • What are rhe semantics around the upper and lower layers? Are they just peers/neighbors or is there a hierarchy such that commands are sent down and requests are sent up, etc? – Jim Sep 6 '17 at 23:32
  • Are these synchronous calls? If you have called “receive_from _up() what happens if “down” calls send_up() before “up” calls “send_down()”? – Jim Sep 7 '17 at 1:12
  • All the classes are able to handle any combination of what you said. There is no strict order or requirements. In the receive_from_up() function buffers are appended to and read out later – portforwardpodcast Sep 7 '17 at 1:36
  • I can't find anything but the opposites like send upward X get downward and send downward X get upward, if at ll possible! – mahmud k pukayoor Sep 7 '17 at 2:19
  • I suggest you have a single receive() call that handles all messages regardless of source. The source can be included as meta-data with the message. – Jim Sep 7 '17 at 6:31
2

I don't think you can avoid ambiguity without using "from". There are several synonyms (accept, intake, etc), but without "from", it's not clear for any of them if the message came from above or below. For example, if you say "accept_up" does that mean you allowed the message to come up, or that it was sent from the layer above?

Using "from" might be a better option, especially if you combine it with "to" for the corresponding functions:

send_to_up - receive_from_down

send_to_down - receive_from_up

Another possibility is to use "send" and "sent". This phrasing is only 2 words:

send_up (sends message up) - sent_up (receives message from down)

send_down (sends message down) - sent_down (receives message from up)

But in this option, the similarity of the names could lead to easy misspelling and thus hard to catch bugs.

| improve this answer | |
1

It looks like you want the names of your methods to be verbs, with the object of the verb being the argument to the method.

Send and receive usually connote the presence of a medium that carries a message, which is why the directional words are important. However, there are other pairs of verbs that do not have such connotations, and might be better choices for your application, e.g.

  • put and take,
  • put and get

It also helps if your method names are easy to distinguish in automated code completion, i.e. the immediate appearance to the reader is not the only criterion. How about:

  • putUp( stuff )
  • putDown( stuff )
  • getUp( stuff )
  • getDown( stuff )

You have to get up before you can put down, and get down before you can put up.


Edited, to address the active/passive issue raised by Andrew Leach:

It's hard to suggest a good naming scheme without some idea of how the layers are coupled.

  • If the sender in Layer A blocks until the receiver in Layer B has replied, then the receiver needs nothing more than a return statement.
  • If the sender can continue with other actions, the OS and/or the language runtime will usually have a preferred way of "waiting" for an event.
  • If the lower layer is some kind of messaging service, the upper layer usually has to subscribe in some way, e.g. by registering a callback object where the method name is predetermined by the object's class or superclass.

Your naming convention may be easier for users to follow if it conforms to the surrounding software, or (if your own code is significant in size), to the Software Design Patterns you have used in your overall architecture.

For example, in the original book by the Gang of Four, the Observer pattern uses the method names Update() and GetState(). If you are using this pattern, also known as publish/subscribe, you can't go wrong using the original names, or something close to them.

| improve this answer | |
  • Except that get is an action, whereas receive [from] is passive. It's not actually going and getting anything; it's waiting and something drops into its lap (so to speak). – Andrew Leach Sep 6 '17 at 22:47
  • @AndrewLeach Totally agree, and I'm hoping that others contribute some more verb pairs, e.g. push and pull. I'm going on the theory that the OP is really just looking for ideas at this point. – Global Charm Sep 7 '17 at 0:14
0

I can't think of a single word for "received from".

However,

For 3 word solutions:

send to up/down, received from up/down.

Or these can be shortened to two word solutions:

to up/down, from up/down

| improve this answer | |
  • Since up and down aren't counted in the OP's examples, your suggestions of to and from are excellent single-word answers in a programming context. Nevertheless, unlike "send up", the phrases "to up", "to down" and so on don't conform to standard English usage. – Lawrence Sep 7 '17 at 22:19
  • I tend to agree that the usage is non standard, however if each layer can only communicate with the one above it and the one below it then a reasonable name for these layers for any given transaction would be “up” and “down” . With “up” and “down” being nouns, the terms “to/from up” and “to/from down” approximate usage that might be found in a letter e.g. To John……… From Paul. – user252684 Sep 7 '17 at 23:24
  • Good point. In that case, I'd prefer the phrases "to above" and "from below" etc, but that would be a further step away from the OP's request. – Lawrence Sep 8 '17 at 1:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.