title: Mapping UML Class Diagram to Python Code
body: <p>I've been asked to document a piece of code using UML diagrams. The code models a situation like the following: a driver can be assigned to one or more routes. Each route has an upstream and a downstream direction. For each route the driver can drive in the upstream direction and/or in the downstream direction. </p>
  
  <p>A simplified pseudo-code is for the Driver class is the following:</p>
  
  <pre><code>class Driver:
  
    HashMap&lt;Route, Direction&gt; upstream;
    HashMap&lt;Route, Direction&gt; downstream;
    HashMap&lt;Route, Direction&gt; assignedTo;
  </code></pre>
  
  <p>where the assignedTo map is actually a property returning a hashmap composed of the routes where the driver is assigned to both the upstream and downstream directions (think of it as a view on the other two hashmaps)</p>
  
  <p>So far I've come up the the following UML representation. </p>
  
  <pre><code>-----------                            ---------
  | CLASS   | (assignedTo)               | CLASS |
  | DRIVER  |----------------------------| ROUTE |
  ----------- *   |                    * ---------
                  |
              -------------
              | CLASS     |
              | DIRECTION |
              -------------
                ^        ^
                |        |
        ------------    --------------    
        | CLASS    |    | CLASS      |
        | UPSTREAM |    | DOWNSTREAM |
        ------------    --------------
  </code></pre>
  
  <p>However, I'm a little puzzled by the fact that in the UML I;m using inheritance while the code uses no inheritance. What do you think?</p>