Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

(design) sending integer codes from backend to UI

 
Pho Tek
Ranch Hand
Posts: 782
Chrome Python Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My application is divided into a client and server.

The server sends results back to the client for display.

A sample of the result:

On the client side, it should display the results as:

Should I sent back the values with the translated status codes (in string format) or should I just send the integer codes as shown (and let my client translate it) ?

Comments/brickbats welcomed.

thanks
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could have lookup codes on the client side or you could do this on the server's side as well. If your client and lookup codes are likely to change a lot it would be better to do it on the server.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15272
37
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would say use the first option - make the server send back the codes, and make the client convert the codes into strings for display.

It's a good design principle to keep business logic and the user interface separated. Suppose that in the future you don't want to use strings, but you create a fancier client that displays icons for the different states instead of text strings. What would you do then - change the server to make it return icons? User interface logic belongs on the client.
 
Pho Tek
Ranch Hand
Posts: 782
Chrome Python Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jesper, you've convinced me with your argument. Thanks.

Thanks to John for contributing ideas as well.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic