A very quick question. Do you hardcoded the list of airport codes for the combo boxes displaying the flight origin and destination? I am still thinking whether I should hardcode it or create a list from the database. Theoretically, hardcoding is not a good approach, but reading it from the second and third column of the db.db and then building a unique list is not a good approach either. It is so troublesome.
I think it would be considered very bad code habit to hardcode values that are dependent of the database used. This is true generally and in this case specifically since it�s highly likely that the database file could be expanded with more destinations/origins; possibly even by the examiner when testing! So in my opinion: don�t hardcode these values. It could probably result in a penalty since it's bad coding style and the assignment hints that we should have the expansion possibilities in mind. /A J Skantz
I have to admit that I don't even provide dropdowns for these values, just plain textfields. The reason for this: If I want to fill the combos from the DB i have to go through each and every record to find all existing values for Origin and Destination, which could be very slow via RMI. Rainer
Rainer<br />SCJP, SCJD, SCWCD
posted 19 years ago
Rainer, I think the airport code list is just a one time downloading during the screen booking initialization, isn't it? After the downloading, there should not be any degrade in performance.
posted 19 years ago
Yes, it's just a one time think. But I use a general purpose Data server where you can only retrieve a complete record. Therefore during init the client has to download all records completely. Not a thing that I would do for 1000s of records... The other alternative is to provide specific methods on the server (like book() and in this case: getAirports()). But that's not my way as I want to keep the DB-Server generic. Rainer
As a unit\system testing convenience I listed 5 origin and departure codes in JComboBox. I indicated in a tool tip that these were the "Top 5 Destinations" or "Top 5 Origins" . This indicated my disdain for hard coding and my sensitivity to a large db query. Which I echoed in my write up. I lost no points on my GUI. So I think this is o-kay. Good Luck
I have implemented String getDistinctValuesForField(int fieldNum) method in the Data class on the server side which simply returns the distinct values for the specified field. To minimize unnecessary processing, the distinct values are calculated at the time of constructing the object of Data class and kept in a cache (Set)- the cache needs to be updated only on the addition or deletion of record. I think this method retains the generic nature of the database, and efficiently provides the client with what it wants.