title: Argument passing strategy - environment variables vs. command line
body: <p>Most of the applications we developers write need to be externally parametrized at startup. We pass file paths, pipe names, TCP/IP addresses etc. So far I've been using <strong>command line</strong> to pass these to the appplication being launched. I had to parse the command line in <code>main</code> and direct the arguments to where they're needed, which is of course a <em>good design</em>, but is <em>hard to maintain</em> for a large number of arguments. Recently I've decided to use the <strong>environment variables</strong> mechanism. They are global and accessible from anywhere, which is <em>less elegant</em> from architectural point of view, but <em>limits the amount of code</em>. </p>
  
  <p>These are my first (and possibly quite shallow) impressions on both strategies but I'd like to hear opinions of more experienced developers -- <strong>What are the ups and downs of using environment variables and command line arguments to pass arguments to a process?</strong> I'd like to take into account the following matters: </p>
  
  <ol>
  <li>design quality (flexibility/maintainability), </li>
  <li>memory constraints, </li>
  <li>solution portability. </li>
  </ol>
  
  <hr>
  
  <p><strong>Remarks:</strong></p>
  
  <p>Ad. 1. This is the main aspect I'm interested in. </p>
  
  <p>Ad. 2. This is a bit pragmatic. I know of some limitations on Windows which are currently <a href="http://msdn.microsoft.com/en-us/library/ms682425.aspx" rel="noreferrer">huge</a> (over 32kB for both command line and environment block). I guess this is not an issue though, since you just should use a file to pass tons of arguments if you need. </p>
  
  <p>Ad. 3. I know almost nothing of Unix so I'm not sure whether both strategies are as similarily usable as on Windows. Elaborate on this if you please. </p>