Slashdot is powered by your submissions, so send in your scoop

 



Forgot your password?
typodupeerror
×
Programming

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?"
This discussion has been archived. No new comments can be posted.

Naming Bi-Directional Streams In an API?

Comments Filter:
  • Use foo and bar. Everyone understands that.

    • by Anonymous Coward

      Just don't cross them.

  • server-client (Score:3, Insightful)

    by Anonymous Coward on Sunday January 30, 2011 @07:12PM (#35051542)

    Why not call them the "client to server" stream and the "server to client" stream?

    • by OFnow ( 1098151 )

      The X-windows naming example proves that it's unclear what client and server
      really mean!

      • 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

  • by Anonymous Coward

    Look at the purpose of the streams. Possible options are "request"/"reply", "control"/"media", etc.

  • by snikulin ( 889460 ) on Sunday January 30, 2011 @07:29PM (#35051714)

    UploadStream: data goes to a server.
    DownloadStream: data goes from the server.

  • Just as described in some of the prior posts, I'd prefer UploadStream and DownloadStream. But if for some reason you don't want to use those names, how about StreamToServer and StreamToClient ?
  • 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.

  • socket syntax (Score:3, Insightful)

    by chaostaco ( 1233722 ) on Sunday January 30, 2011 @07:46PM (#35051838)
    The syntax from socket programming, like send, receive, and listen, seems well suited for situations where both sides can act as clients or servers. Both sides would use the same syntax, each naming things from its own perspective.
  • by NevarMore ( 248971 ) on Sunday January 30, 2011 @07:57PM (#35051894) Homepage Journal

    ...I think you want StackOverflow [stackoverflow.com] which is a few clicks that way ------>

    • by subreality ( 157447 ) on Sunday January 30, 2011 @09:19PM (#35052392)

      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?

  • ...but the SEND/RECEIVE pins between modem and computer are always named from the perspective of the computer. There's precedent to use server-centric nomenclature.
    • by msauve ( 701917 )

      but the SEND/RECEIVE pins between modem and computer are always named from the perspective of the computer. There's precedent to use server-centric nomenclature.

      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

  • 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.

    • by gl4ss ( 559668 )

      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.

    • by mcmonkey ( 96054 )

      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

      • 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

  • by decora ( 1710862 ) on Sunday January 30, 2011 @11:14PM (#35053020) Journal

    although "eat me" "drink me" is a close second

  • by Anonymous Coward

    why not produce(er) and consume(er) as in the messaging world?

  • or is that too obvious?
  • by LostMyBeaver ( 1226054 ) on Monday January 31, 2011 @04:40AM (#35054412)
    Media frameworks such as DirectShow, GStreamer and the such are quite good at this. I work on this specific type of code all day long and maintain my own alternative for extremely high bit-rate environments.

    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.
  • 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

  • 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....

  • by juancn ( 596002 ) on Monday January 31, 2011 @11:02AM (#35056428) Homepage
    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.
    • 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.

  • ... 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.

  • The InputStream is the one being read from and the OutputStream is the one bing written to. The same stream will be called both depending on which side you're looking at.
  • 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

Get hold of portable property. -- Charles Dickens, "Great Expectations"

Working...