• 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

configure using properties rather than arguments ?

 
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the preferred technique for specifying variables to a program (such as the datasbe filename, the operating mode etc).
specifying them as arguments hard wires the order of the parameters in the command line, and makes the validation within the main method a bit more lengthy.
where as specifying them as properties, removes the restriction on order, and is really easy to validate - it generally seems a more flexible, solution.
currently i am using properties, but is this going against any convention ?
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Using property file for configuration is always a good idea. Because you can change it without changing code.
The downside of it, is teaching the user how to set it up correctly. But you would have to teach the users the correct command line arguments to pass also.
I don't know if it would have an effect on your scoring though.
Mark
 
dean tomlinson
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi mark - thanks for your response.
just to clarify, i am not using a properties file for configuration in this assignment as it says that the examiner must not have to edit any files.
i always use a properties file, for the configuration of the web applications i develop commercially.
what i mean't for the assignment was is it ok/prefered to use ...


java -DflightDatabaseName=db.db -DoperatingMode=R -DdataServerHost=localhost suncertify.userinterface.FlyByNightController


as opposed to


java suncertify.userinterface.FlyByNightController db.db R localhost

 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I always liked the second way better, it is easier for me to read, but that's just me.
Mark
 
reply
    Bookmark Topic Watch Topic
  • New Topic