Naming Bi-Directional Streams In an API? 61
DingoTango writes "My coworker and I are designing an infrastructure API to manage data streams. It will allow a client developer to set up streams going to and from some invoked server functionality, and allow a server developer to write services that both consume and produce streaming data. Our quite civil disagreement involves naming: From the perspective of the client platform, the client's output stream goes to the server, and input stream comes from it. For the purpose of any ensuing discussion, let's call this the 'Local' perspective. However, if the client developer considers the service to be a widget, then the stream going to the service is the input stream and the stream coming from it is the output. Let's call this the 'Widget' perspective. As this is an infrastructure utility, we aren't able to name the streams according to function. What say ye, Slashdot? Is there any precedence, experience, or ungrounded yet vociferous opinion that will resolve this for us?"
When in doubt (Score:2)
Use foo and bar. Everyone understands that.
Re: (Score:1)
Just don't cross them.
server-client (Score:3, Insightful)
Why not call them the "client to server" stream and the "server to client" stream?
Re: (Score:2)
The X-windows naming example proves that it's unclear what client and server
really mean!
Re: (Score:2)
Not so much. People are just used to "client" meaning "local", which isn't always the case. In the case of X, the graphics acceleration and rendering are a service provided by one software system to many other software systems, which are your applications. The applications are therefore the clients consuming a service provided by X, which is the server.
There is some minor confusion in that you can use the computing resources of the same system on which X resides to run the applications or you can use the co
Re: (Score:1)
Or name the first one "not_fast" and the other one "enough"
Re: (Score:3)
Indeed, upload and download were highly directional and even connotated the initiator. Unfortunately the terms have become corrupted where an upload became synonymous with outgoing data transfer and download with incoming data transfer, and both terms being applied to the same transfer, disregarding the initiator (particularly in torrenting software).
You push a file: you send an upload, the remote machine receives your upload; you pull a file: the remote machine sends you a download, you receive that downlo
Direction doesn't matter (Score:1)
Look at the purpose of the streams. Possible options are "request"/"reply", "control"/"media", etc.
UploadStream and DownloadStream? (Score:3, Interesting)
UploadStream: data goes to a server.
DownloadStream: data goes from the server.
StreamToServer / StreamToClient (Score:1)
Ends (Score:1)
Look from each component and the input and output streams based on that.
The client's output stream is the server's input stream, the server's output stream is the client's input stream.
The widgets output is the clients input and the widget's input is the clients output.
Re: (Score:3)
I would call one of the streams "input" and the other one "send"
Otherwise it just gets too confusing.
socket syntax (Score:3, Insightful)
Excuse me sir, this is a news site... (Score:4, Informative)
...I think you want StackOverflow [stackoverflow.com] which is a few clicks that way ------>
Re:Excuse me sir, this is a news site... (Score:4, Insightful)
Not really. Ask Slashdot has always had a little niche for this.
It's a fun question, too. I'd suggest naming them directions that don't correspond to client-server relationships in such an obvious way. So, instead of Up and Down, go for North and South, whichever way feels more appropriate to the situation. In and Out might be a good pair, depending what you want to visualize.
How about Hitherwise and Yonderborne?
Re: (Score:1)
Thisaway and thataway? Better: deosil and widdershins.
Re: (Score:2)
Better: deosil and widdershins.
I am disgusted by your attempt at Northern Hemisphere cultural imperialism!
Re: (Score:2)
Ok, you started it:
To and Fro
Ying and Yang
Tweedle-dee and Tweedle-dum
Re: (Score:1)
Just as how modems send and receive... (Score:3)
Re: (Score:2)
No, they are named from the perspective of the DTE (Data Terminal Equipment). When the RS-232 standard was created, that meant a terminal or a computer. It was "reverse named" from the perspective of a DCE (Data Communications Equipment), which was often a modem.
Mapping that to client/server fails, because both the display terminal (which would pro
Do they have to have the same names on both ends? (Score:3)
I can definitely the benefit of names pairs such as "Upload"/"Download" or "toServer/toClient" or "toServer/fromServer". Those all work when you've got a clear client/server orientation. But, if you're talking about more distributed situations where you have more of a peer orientation, those break down.
If you can name them separately in the client and in the server, why not use names that are meaningful to the local context? For example, the client's output stream goes to the server's input stream, and vice versa? You've got good precedent for that today in UNIXland with stdin and stdout. Consider a pipe: One side writes to its stdout, and the other side reads it from stdin. Seems perfectly logical to me.
Re: (Score:2)
name them from the perspective from which they're used from the api. that is, functions that take data to be sent elsewhere would be named 'send'(or upload) and 'get','receive' or similar would be the other direction.
but this seems like a case of where they should have just named them john1 and doe3 or _anything_ so they could have moved on with their design, if things go this way then next week they can argue about package names.
Re: (Score:2)
I have 3 questions:
1) Why isn't this the highest modded comment in the thread?
2) Why are others continuing to post after this solution? I mean, why would you do anything other than name the stream coming in to the server as the input stream in the server context, the stream coming from the client as the output stream in the client context, and so on?
3) How long until the entire project crashes in complete disaster? Does it really take 2 developers to figure this out? The only other scenario I can think o
Re: (Score:2)
Does it really take 2 developers to figure this out?
No, one developer on their own would have figured it out. It takes two developers to make it an issue. ;c)
At first, I didn't understand what all the fuss was about, because I gathered that the server functionality always behaved like a filter. If that is the case, then just treat it like a black box; don't even muddy the waters with the fact that this box is doin' its thing "out" on a server somewhere else. The stream I feed it is 'in', the stream it gives me back is 'out'. No big deal, whether I am de
car and cdr, obviously (Score:3, Insightful)
although "eat me" "drink me" is a close second
produce(er) consume(er) (Score:1)
why not produce(er) and consume(er) as in the messaging world?
Prosumption (Score:2)
How about "From" and "To"? (Score:1)
You should look to media frameworks for this (Score:3)
You're talking about designing an object that consumes and produces real-time data. The source of this data is provided by an "upstream" component (or object to be consistent) within your processing pipeline. The destination for the data produced is provided to a "downstream" object.
An API for this type of component should always been seen from the perspective of the user of the component or object. Therefore the interfaces should be named NOT from their internal perspective, but from their external perspective. After all, your APIs are theoretically there so that someone else can use your component without being familiar with the internal architecture of the component itself.
An upstream component which provides data to downstream components are "Data Sources".
A downstream component which consumes data provided by "Data Sources" are "Data Sinks"
A component which acts on data received from an upstream "data source", alters it or produces new data from to send down stream to a "data sink" is called a "transformation" object.
So, a processing pipeline should consist of 3 elements.
1) Data source
2) Transformation Object
3) Data sink
This is similar in nature to :
1) Input
2) Process
3) Output
Though in an object oriented model making use of a pipeline style pattern, it's best to name the objects appropriately.
The output of an object, or the API of an object which provides data to downstream elements, components, objects (etc) should be referred to as Source. So a "Source Object" outputs its data through a "Source". In GStreamer for example, you would say "The source element provides data to downstream elements through one of its source pins" as GStreamer (like other pipeline architectures) provides a uniform interface for providing and consuming data.
The input point of an object (which receives data from upstream objects) should be called a "Sink".
A transformation element contains a minimum of one source and one sink. Data is received by the object via its sink and the processed data is pushed from the object via its source.
This methodology is very simple to use and understand.
An alternative can be "Receiver" which suggests the object received media via this interface and "Transmitter" which suggests that the object transmits data from the interface.
Some people like to use "Listener", "Observer" etc... but since there's no nice corresponding opposite to either of these, I find them grotesque when I encounter them in code.
I think that if you read up on the GStreamer documentation web site, you'll get some great ideas for how best to handle this. Just remember that when you're providing an API to a customer, you're delivering something that should be easy to use and understand from their perspective from the outside. Your API naming should reflect this.
Everything but the kitchen..... (Score:2)
.... Sink and Source?
How about simply "stream" and "client"? (Score:2)
The server just happens to be a well know location for a service that can be connected to. The client initiates the connection. Once the connection is establised the "server" and the "client" effectively become "clients" of each other, when the output of one is plugged into the input of the other.
For example, in .net land (it's where I am, forgive me) you have a TcpListener on the server side. Then when a client connects using a TcpClient, the server creates a corresponding TcpClient on the server side. Wri
really? i mean seriously? (Score:1)
You guys are setting up a post for a story about naming conventions, when we have so many other news posts that could take precedence.... ...here is one, whatever the providing server's owner decided....as it is they that pay the bills for the server and the in house development, so if they feel like calling the service or widget, porky_pig-IS**my_(FRIEND)....who cares....
What's the most common use (Score:3)
What choice will cause the least astonishment to your users?
This is a usability problem. Do what will confuse your user the least. Ask them if you have to.
Write code for both cases against your API. Use it and see what works and what doesn't.
There is no easy answer, this is a design question and aesthetics matter, hence it's rather subjective.
In any case, take into account if your target development platform uses any conventions, and if so stick to them.
Re: (Score:1)
Think of use cases. What are the clients of your API be doing the most? What choice will cause the least astonishment to your users? This is a usability problem. Do what will confuse your user the least. Ask them if you have to. Write code for both cases against your API. Use it and see what works and what doesn't. There is no easy answer, this is a design question and aesthetics matter, hence it's rather subjective. In any case, take into account if your target development platform uses any conventions, and if so stick to them.
I agree, the most common usage of your Stream API is where you should derive the names from Also you should think of who will be using this, are they experienced developers?? If so, then they probably just need a clarification of which is which in your documentation, and they should be fine with either version. Just my 2 cents, from a programmers perspective.
It's arbitrary (Score:1)
... so just pick one and stick to it.
I'm partial to "input" and "output" myself, from the perspective of the object using them (so a client's output goes to the server's input and vice-versa).
If you need to reference both objects' streams at the same time, you've got "myInput", "myOutput", "hisInput", and "hisOutput" for clarity.
Or just pick something fun; "spinwise" and "widdershins" isn't bad, but may confuse your users.
Simple (Score:2)
Why not do both? (Score:1)
I think I see your dilemma. If I understand correctly, you are examining the perspective of the client developer that might approach the server in client-server mode, in which case upStream/downStream (or something of that nature) would work nicely. Conversely, the client developer might be working with a widget that appears to him/her as any other client side object. In this case you can use in/out terminology and simply forward the call to the up/down methods respectively. Interesting names could also be