• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Combo Box for flight origin and destination

 
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I will populate mine from the database, Thus, you can update database without having to recode your combo box.
Hope this helps.
 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Rudy Yeung
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
R Bischof
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
DevilDog
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh.. the JComboBox was editable..
 
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!,
Are full names showed in the combo box or just the codes.
reply
    Bookmark Topic Watch Topic
  • New Topic