Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

configure using properties rather than arguments ?

 
dean tomlinson
Ranch Hand
Posts: 94
  • 0
  • Mark post as helpful
  • send pies
  • 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 ?
 
Mark Spritzler
ranger
Sheriff
Posts: 17276
6
IntelliJ IDE Mac Spring
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
Sheriff
Posts: 17276
6
IntelliJ IDE Mac Spring
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic