title: Design- Pattern to prevent unassigned objects
body: <p>I often get some resharper warnings regarding "unassigned objects created with 'new' expression". Following code snipped shall demonstrate the situation:</p>
  
  <p>I am using a helper class(<code>Observer.cs</code>) which monitors some properties from an other class (<code>MonitoredClass.cs</code>). When a property changes, the observer class writes the changed value into a other data class (<code>DataClass.cs</code>).</p>
  
  <p>simplified code snipped:</p>
  
  <p>MonitoredClass.cs:</p>
  
  <pre><code>public class MonitoredClass : INotifyPropertyChanged
  {
     // simplified: in fact property calls OnPropertyChange(..)
     public string Property1 { get; set; }
  }
  </code></pre>
  
  <p>DataClass.cs:</p>
  
  <pre><code>public class DataClass
  {
     public string LastProperty1Value { get; set; }
  }
  </code></pre>
  
  <p>Observer.cs:</p>
  
  <pre><code>public class Observer
  {
     private MonitoredClass _monitoredClass;
     private DataClass _dataClass;
     public Observer(MonitoredClass monitoredClass, DataClass dataClass)
     {
        _monitoredClass = monitoredClass;
        _dataClass = dataClass;
        _monitoredClass.PropertyChanged+=MonitoredClassPropertyChanged;
     }
  
     private void MonitoredClassPropertyChanged(..)
     {
        _dataClass.LastProperty1Value = _monitoredClass.Property1;
     }
  }
  </code></pre>
  
  <p>So far so good. </p>
  
  <p>If I use now my Observer class from above as follows:</p>
  
  <pre><code>...
  new Observer(monitoredClassInstance, dataClassInstance);
  ...
  </code></pre>
  
  <p>than I get a resharper warning "possible unassigned object created by 'new' expression". </p>
  
  <p>My question now is, if there is a better solution/pattern to design this observer.
  Of coarse, i can allocate the new observer instance to a private field. But than I have a field which is never used. 
  Or I can set the monitoredClassInstance and dataClassInstance with properties instead of pass them in the constructor. But this only prevents the warning, but in fact does not change the architecture.</p>
  
  <p>Thanks in advance for your advice, opinion, pattern etc.</p>