Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

TableModel Data Type

 
William Ni
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Do you guys use the database schema information in the instruction given by SUN? In particular, when creating the table model, will you assume that the 4th column is room size and therfore it should be an Integer type; the 5th column is smoking and it should be a Boolean type? I am doing the URLyBird assignment by the way.
The reason I raise this question is that the default render for Number is right-aligned label and for Boolean is a check box; the default editor also provides with error checking. They are quite handy.
The pros to use this information is that it saves our code to have a nice appearnce of GUI. The cons is that it is not flexible. When the database format changes, even when two columns of the database switch their positions, I have to modify the code.
So, how do you guys do with it?
Thanks.
[ October 18, 2004: Message edited by: William Ni ]
 
Kai Witte
Ranch Hand
Posts: 356
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello,

in my assignment the only editable field was a "customer id". Since it did not state anywhere explicitly that it has to be a number I used a String type for it, and also for all other fields.

I got a very poor score for the GUI (which might be related to that, too). 24/40 for the GUI, but 100 % for the rest.

In your case: The idea of a flexible design is not that the user has disadvantages. Try to make both things perfect, flexibility and reusability of your code and a very good interface for the user. The outer appearance of the program should be designed without thinking about things only a programmer understands. However, I always kept my project very close to the minimum requirements and it payed off.

Most important: Don't take GUI design hints from me!

Conan
 
William Ni
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply, Conan.
You have almost got a perfect score. Congratulations!
Maybe I didn't make the point clear. I try to have a nice and professional GUI. Let's take the "room size" column for example. If I depends on the information given by the database solely, I would never know the 4th column is "room size" and it would be taken as a String. When it appear on the GUI, it would be rendered to be left-aligned. However, if we can make use of the information on the instruction given by SUN, we know the 4th column is "room size" and it should be an integer. When an integer appears in a table, it would be right aligned in its cell.
In my opinion, numbers in a table should always be right aligned in their cells unless there are some specific reasons. This is what I mean by "professional".
As for the Boolean type, don't u think a checkbox looks nicer than a single letter "Y" or "N"?
 
Kai Witte
Ranch Hand
Posts: 356
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello,

no, it obviously was me who didn't make the point clear:

Do it! Use Boolean / Integer where this seems appropriate!

As you said it is hard to make the program flexible when doing so (database format changing). But flexibility has not been invented to make life harder for the user, but to make it simpler for the programmer. When those two things seem to be in conflict, the rule of thumb is: User first!

I saw designs that made both things possible: Simple adjustment for other database formats (even at runtime!) and a type adjusting table. But none of them was very simple or easy to configure for the user.

I'm quite sure that at least the Boolean for smoking / non smoking is almost a must for full GUI score.

Make sure you handle illegal file format (neither "Y" nor "N" for smoking field).

Conan
 
Weerawit Maneepongsawat
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi William,
i've same problem with you, i think we can put data type in property file [IMO]. what do you think?
 
Inuka Vincit
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Weerawit I was thinking along the same lines as well. But the specs calls for the GUI setttings to be storered in the property file. Therefore I was thinking using a builder pattern to define the database record types where the main program is constructed and pass it to both the database and client object constructors. I am also in the GUI part, seems almost as many design desctions to make as the data and business layers.
 
Weerawit Maneepongsawat
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Inuka Vincit:
Weerawit I was thinking along the same lines as well. But the specs calls for the GUI setttings to be storered in the property file. Therefore I was thinking using a builder pattern to define the database record types where the main program is constructed and pass it to both the database and client object constructors. I am also in the GUI part, seems almost as many design desctions to make as the data and business layers.


How do you know data type in Db file? in my instruction.html had only Database schema..

 
Inuka Vincit
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Weerawit Maneepongsawat:


How do you know data type in Db file? in my instruction.html had only Database schema..



The way I interpreted it is that the DB file hearder describes the data type in the db file. We use this information and the cookie value to check to see if we are reading a correct file. Not sure if am over doing the checking of the data file.
 
William Ni
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems everyone agrees on that we can make use of the database schema.

I made the following assumption for the data types. please correct me if I am wrong.
name String
location String
size Number
smoking Boolean
rate String (but right aligned)?
date String
owner Number | String

I prefer to use String for the owner field, though the instruction says it's an 8 digit number. Could the 8 digit number be something like "00012345"?
 
Weerawit Maneepongsawat
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by William Ni:
It seems everyone agrees on that we can make use of the database schema.

I made the following assumption for the data types. please correct me if I am wrong.
name String
location String
size Number
smoking Boolean
rate String (but right aligned)?
date String
owner Number | String

I prefer to use String for the owner field, though the instruction says it's an 8 digit number. Could the 8 digit number be something like "00012345"?



I think we can use Number for rate, you can parse by NumberFormat obj
Do you hardcord this in your application?

I just want to generate datatype when user select a db file..Any solution?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic