wood burning stoves 2.0*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes configure using properties rather than arguments ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "configure using properties rather than arguments ?" Watch "configure using properties rather than arguments ?" New topic
Author

configure using properties rather than arguments ?

dean tomlinson
Ranch Hand

Joined: Jan 31, 2002
Posts: 94
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

Joined: Feb 05, 2001
Posts: 17249
    
    6

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


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
dean tomlinson
Ranch Hand

Joined: Jan 31, 2002
Posts: 94
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

Joined: Feb 05, 2001
Posts: 17249
    
    6

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
 
subject: configure using properties rather than arguments ?
 
Similar Threads
maven/ant/ldap problems
"include" capability?
NetBeans passing entry parameter for main
accessing a .properties file
Args in Netbeans