On Wed, 22 Jan 2003, Trevor Morris wrote:
> Date: Wed, 22 Jan 2003 21:40:56 -0500
> From: Trevor Morris <[EMAIL PROTECTED]>
> Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Subject: data types on the travel between DB and view -- best to make
> everything Strings?
>
> Where and when do you do data conversion between the DB, Business, and View
> levels? When you grab data out of the DB and set them in your VOs, do you
> set dates as Dates, ints as ints, etc? Or is it easier to just leave
> everything as Strings and pass them around. The majority of data in web
> apps is only used for display. Little data has any logic performed against
> it. If it does, you can just cast the String to the appropriate type when
> needed.
>
> String number1;
> String number2;
>
> e.g. if (Integer.parseInt(number1) < Integer.parseInt(number2) {}
>
> What purpose really is there in keeping the data in their native types? If
> you do, you have so much work to do in the transfer between the view and
> business layers.
>
If you convert dates to some string-based format in your VOs, how do *you*
know that you've selected the one-and-only format that all your users will
ever want to display dates in? What happens when you want to support
international users that want to select their own date formats, based on
the Locale setting for that user?
My advice is to keep your VOs using native (locale-independent) data
types, and let the tags (if you're using JSP) or other conversion
mechanism do the appropriate locale-sensitive formatting.
Form beans, on the other hand, should generally use Strings for things
that are going to be represented as HTML input fields -- for reasons that
have been discussed hundreds of times before in the STRUTS-USER archives.
> Thanks for any advice.
>
> Trevor
Craig
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>