| Author |
(design) sending integer codes from backend to UI
|
Pho Tek
Ranch Hand
Joined: Nov 05, 2000
Posts: 757
|
|
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
|
Regards,
Pho
|
 |
Deepak Bala
Bartender
Joined: Feb 24, 2006
Posts: 6592
|
|
|
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.
|
SCJP 6 articles - SCJP 5/6 mock exams - SCJP Mocks - SCJP 5 Mock exam (Word document ) - SCJP 5 Mock exam in Java.Inquisition format
|
 |
Jesper de Jong
Java Cowboy
Bartender
Joined: Aug 16, 2005
Posts: 12929
|
|
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.
|
Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
|
 |
Pho Tek
Ranch Hand
Joined: Nov 05, 2000
Posts: 757
|
|
Jesper, you've convinced me with your argument. Thanks. Thanks to John for contributing ideas as well.
|
 |
 |
|
|
subject: (design) sending integer codes from backend to UI
|
|
|