1

Here's a simple scenario:

We have a list of tasks and can mark a task as completed by invoking a web service. Doing so will transition the status of the task to completed as well as initialize a completedOn data member.

Is it a good practice for services to return additional data members required for the UI to sync the client data state? To me, it feels a bit weird that the markTaskCompleted service or PUT /tasks/completed/ ... returns a completedOn data member in the response.

What's the preferred way of dealing with similar situations in the industry? Is there a widely adopted practice?

In the above case, I could probably just infer the completedOn value client-side, but that's not always possible.

1

As far as I can tell, there's no reason to be concerned about a field like completedOn. Can you say more specifically about what concerns you? It would help us to understand your concerns if you could provide an example of an implementation that you think is more correct.

There are some downsides to determining the time stamp on the client in my view, mostly around clock synchronization, timezones, and multiple clients having different ideas of the value of the time stamp.

Edit: One thing to consider is where the actual knowledge that the task was completed takes place. If the task is executed and complete on the client, then the client can and should be responsible for setting the time. If the task executes and completes on the server, then the completedOn field should be set there.

  • Well, it could be as simple as the completion date must be displayed on the UI after a task is marked completed. Should the UI issue a new request to retrieve the task entity as a whole (which would now have the completedOn) or is it ok for such services to return data which is expected to be synchronized on the client? – plalx Jun 4 '15 at 17:30
  • 1
    Any one of those is probably fine depending on your use case. – RibaldEddie Jun 4 '15 at 17:34

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.