Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

passing 'mode' as one of the command line parameters

 
Rasika Chitnis
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Currently, I do not let user specify the mode within the GUI. The program runs in the specified mode when it was started. So, I expect a string 'local' or 'remote' as one of the command line parameters. I read in this forum somewhere that asking user to type in mode is not permissible. In my instructions they do specify the possible command line parameters and mode is not one of them.
But I do not see any other reasonable way to figure out the mode only based on either file name or host name. Unless I try to instantiate the Data class with the only parameter I get from user (it could be file name or host name, port number is optional) and if it throws exception, I will not know if user entered filename or hostname. Even when there is exception thrown by Data class, it could be for two reasons file does not exist or it is not a file name.
The other way is to make port number mandatory and then the number of parameters will tell if user intends to run the program in local or remote mode. I feel it is rather clumsy to do this way.
Appreciate anyone's rely on this. Thanks
 
Rasika Chitnis
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anybody please give feedback on this ? Am I to assume that one command line parameter means it is local mode and two command line parameters mean remote mode ??
thanks
 
Rasika Chitnis
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One more point:
If I have to make user type in two parameters, just because I am using it as a way to distinguish between local and remote mode, I am forcing user to enter port number even if it is a default port. If I do not consider number of parameters as a test of local/remote, I could use default port in my code if user did not give me one.
Relying on number of parameters to decide if the mode is local or remote, seems odd to me.
Anyone, please respond >>>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic