views:

73

answers:

5

We're in the process of creating a new API for our product, which will be exposed via web services. We have an internal debate whether the API should be as easy as possible to use (in the price of making more calls) or make it as efficient as possible (rendering it harder to use). For example, here are two issues that came up:

  • Should we manage session info on the server, or should we pass that info back to the user, and expect him to send it back to us when needed? (Please ignore the security implications of a session)
  • Should we combine calls that are likely to be consequent, in order to save the time spent on the round trip in between, even if they don't really share the same logical functionality?

Basically, the desktop people are in favor of a clear, easy to use API, while the internet people would like to make it as efficient as possible. This is the first public API we're providing, and we need a strategy.

Personally, I'm in favor of making the API as usable as possible. Other components on the system are probably going to have a much larger affect on the performance, and hard to use APIs are much more error prone. But I'm a desktop programmer…

So, what should be our strategy? What are the common practices when creating such an API?

A: 

IMO, the best is to have the simplest API for people who will have to use your API, but letting these people have deep customizing possibilities, to make it efficient, even if harder to use.

But simplicity for users > all.

Clement Herreman
+1  A: 

What are typical usage scenarios? Will the latency of your API determine the UI responsiveness? How big the performance trade-off will be? It's hard to suggest anything without knowing your circumstances.

But

  1. My guess is that passing session info to the client will scale better. In-proc session management won't allow you to share the state between service instances. Managing sessions in DB will make your services more complex. Anyway this all depends on your bandwidth/memory/computational power capabilities.

  2. I would start from the most granular operations and only provide composite methods when performance problem becomes obvious.

Dmitry Ornatsky
We provide a CMS. Our users will create their own web UI, using our application via the WS API. On most cases, the API will indeed affect the UI responsiveness. I know in some cases the details dictate the solution, so I'm looking for a strategy for the cases where both ways are possible.
eran
A: 

I would recommend you create your web service following the RESTful model and that means stateless. Efficiency is more critical than ease of use. You can always create a framework on top of the API later that eases implementation headaches.

Dave Anderson
ForerMedia
@ForerMedia I should probably have used the word performance rather than efficiency but used that as it was in the original post. Surely the internal mechansim of something can be inefficient but easy to use or efficient and difficult to use. Interesting example: ISO 9241-11:1998 Ergonomic requirements for office work with visual display terminals (VDTs) Guidance on usability ;o)
Dave Anderson
@Dave Anderson: the relation between efficiency and ease of use can be related in time of use. if a user uses the UI once, they do not realise how inefficient it is unless they have experienced the UI or similar UI previously. But, when the user realises the inefficiency of the system they will not think it offers ease of use, as it will take too long to achieve the desired result or will need to repeat the task to get the result.
ForerMedia
"[Usability refers to] the extent to which a product can be used by specified users to achieve specified goals with effectiveness, efficiency and satisfaction in a specified context of use." - ISO 9241-11
ForerMedia
A: 

You're debating a circular agrument. This is all usability (ease of use).

You're likely going to factor in a bit of both aspects - as they both influence user performance.

Its a case of (i) extent of customsiable features versus (ii) efficiency in manipulating those features. There will be an intersect between the two.

I'd say give a simple API that puts control into the users hands - this is the primary purpose of CMS. The more detailed aspects you could combine initially, introducing them as added control later on.

This way you will manage users learning curve of the system so as (i) not to bombard them with excessive options initially and (ii) allow them to adopt your system quickly at first. Then extend your users control (system functionality from a user perspective) later on by making more of the API features available.

Another good tip would be to ask you users upfront & as you go.

ForerMedia
Asking somewhat abstract question calls for somewhat abstract answers, so I'll break it down a bit: consider the case of one function that executes a query, and another that gets a range of results. Having the former return the first set of results rather than just the results number or so will eliminate the need of one call of the latter. However, each function takes different arguments and returns different values. Combining them will provide a faster API with combined calls, which will be much less usable. Would your answer apply to a C++ API as well?
eran
ForerMedia
ForerMedia
From your comments I take it we're on the same page. I couldn't quite understand what you meant by saying "The more detailed aspects you could combine initially, introducing them as added control later on". Care to simplify it for a non-native English speaker?...
eran
ForerMedia
A: 

My 2 cents:

First start with a very granular low level API that gives high performance. Then create a easy-to-use high level API that is "composed" of the above low level API.

This way clients can customize their behavior as they want. The clients can start with using the high-level API but if high performance is expected for certain user actions, they can use the faster-but-difficult low level API on a case-by-case basis.

One more important point to consider in service design. Try to keep them as stateless as possible. The advantage of stateless web services is that they can be easily distributed using Network Load Balancing.

Modicom