title: Why use tuples instead of objects?
body: <p>The codebase where I work has an object called Pair where A and B are the types of the first and second values in the Pair.  I find this object to be offensive, because it gets used instead of an object with clearly named members.  So I find this:</p>
  
  <pre><code>List&lt;Pair&lt;Integer, Integer&gt;&gt; productIds = blah();
  // snip many lines and method calls
  
  void doSomething(Pair&lt;Integer, Integer&gt; id) {
    Integer productId = id.first();
    Integer quantity = id.second();
  }
  </code></pre>
  
  <p>Instead of</p>
  
  <pre><code>class ProductsOrdered {
    int productId;
    int quantityOrdered;
    // accessor methods, etc
  }
  
  List&lt;ProductsOrderded&gt; productsOrdered = blah();
  </code></pre>
  
  <p>Many other uses of the Pair in the codebase are similarly bad-smelling.</p>
  
  <p>I Googled tuples and they seem to be often misunderstood or used in dubious ways.  Is there a convincing argument for or against their use?  I can appreciate not wanting to create huge class hierarchies but are there realistic codebases where the class hierarchy would explode if tuples weren't used?</p>