title: DDD Entity and EntityType reference
body: <p>I'm learning DDD and here is a problem I faced. I have two Aggregates (simplified):</p>
  <pre><code>class NoteType : AggregateRoot {
    int noteTypeId
    string name
    string fields[]
    ... code omitted ...
  }
  
  class Note : AggregateRoot {
    int noteId
    int noteTypeId
    map&lt;str, str&gt; fieldValues
  
    setFieldValue(fieldName, fieldValue) {
      // I want to check that fieldName is present in Notes.fields
      // and later fieldValues[field.name] = fieldValue
    }
    ... code omitted ...
  }
  </code></pre>
  <p>I've heard that aggregates should reference to each other by ID's only. It this case I can't access <code>NoteType.fields</code>. I found several ways to do so, but not sure which one is better:</p>
  <ol>
  <li>Pass <code>NoteType</code> instance into the <code>Note</code> model via constructor (do not reference by ID)</li>
  <li>Use repository in <code>setFieldValue</code> to load <code>NoteType</code></li>
  <li>Use service which will do the check (this may cause all the Note logic to be implemented in this service, since Note highly dependent on NoteType)</li>
  </ol>
  <p>What do you suggest?</p>