It's not a secret anymore!
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
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply 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: 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
    
    1

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
    
    3

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.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: (design) sending integer codes from backend to UI
 
Similar Threads
Writing batch file
HashCode and Equals Contract Question from Inquisition Exam
Webspere 345 exam questions
Building C language's binary protocol strings in Java
how to insert space between two values