title: How to design "one of a few available values, that enables further selection" properties (prefereably in C#)?
body: <p>Imagine you need to develop an application, e.g. C# WPF, where a user can select a value for some option, and this selection defines available values for other options, and so on.</p>
  
  <p>For example, let's consider a structure for cars.</p>
  
  <p>A user selects make, model, and trim. All of these properties have a limited and predefined list of available values, like "Toyota", "Honda", "VW", "Ford", "Mazda", etc. for make.</p>
  
  <p>Each manufacturer has a list of available models, like "Golf", "Passat", etc., and each model has some trims, like "SE", "LE", etc.</p>
  
  <p>Selecting a trim, a user can then select other options, like an engine ("V8 Guzzoline" or "Win! Diesel"), "big fat tires, everything", "hardwood floor and stainless steel appliances", etc.</p>
  
  <p>So, we could design a Car class with the following properties:</p>
  
  <ul>
  <li>Make</li>
  <li>Model</li>
  <li>Trim</li>
  <li>Options</li>
  </ul>
  
  <p>"Options" would be probably a separate class. I have a problem with those "one of a few available values, that enables further selection" properties, though.</p>
  
  <p>We could use some enums for them ("one of a few available values") and then a monstrous "if-else" factory method to create a proper car object. However, these enums would be different for models and trims for all manufacturers, and basically different enum types destroy these class hierarchy.</p>
  
  <p>We could use just strings, like this:</p>
  
  <pre><code>public class Car {
      public string Make {get; set; }
      public string Model {get; set; }
      public string Trim {get; set; }
      public CarOptions Options {get; set; }
  }
  </code></pre>
  
  <p>but this is error prone, and it's tricky to ensure that the selected value is one of the predefined values.</p>
  
  <p>This task seems quite common, but I couldn't find a flexible solution so far to build the class hierarchy. I wonder if there are some patterns that I'm missing.</p>