File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes (design) sending integer codes from backend to UI Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "(design) sending integer codes from backend to UI" Watch "(design) sending integer codes from backend to UI" New topic
Author

(design) sending integer codes from backend to UI

Pho Tek
Ranch Hand

Joined: Nov 05, 2000
Posts: 761

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: 6661
    
    5

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 - More SCJP Mocks
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14266
    
  21

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 8 API documentation
Pho Tek
Ranch Hand

Joined: Nov 05, 2000
Posts: 761

Jesper, you've convinced me with your argument. Thanks.

Thanks to John for contributing ideas as well.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: (design) sending integer codes from backend to UI