title: Observer pattern or Callback?
body: <p>I have to do a design of a <code>DownloadManager</code>, but my main question is related to the notifications that a <code>Download</code> can send to the <code>DownloadManager</code> like <code>onUpdate()</code> to update a progress bar, <code>onError()</code>, <code>onFinish()</code>, etc. Somehow the <code>DownloadManager</code> has to receive this notifications from its <code>Download</code>s.</p>
  
  <p>I've thought 2 possible ways:</p>
  
  <ul>
  <li>Observer pattern</li>
  <li>Callbacks</li>
  </ul>
  
  <p><b>Observer pattern</b></p>
  
  <p>Basically there are 1 Observable and N Observers. In my case the DownloadManager has te be an Observer and the Downloads the Observables, so the relation is N Observables 1 Observer, just the opposite.</p>
  
  <p>The advantage is to centralize all the possible notifications in one method, the <code>notify()</code> or <code>update()</code> (from java) method from the Observers, in my case only the DownloadManager. I can pass a param to the notify() method with the code of the notification.</p>
  
  <p>Disadvantage? I'm using an oop pattern for a thing that can be done easily with a callback. Also, N observables 1 observer it's something weird, at least with the observer pattern because this pattern was done for 1 observable N observers, so I really won't be using the observer pattern.</p>
  
  <p><b>Callback</b></p>
  
  <p>Very similar to the observer pattern. The DownloadManager implements a "listener" (interface). This listener implements the notification functions onFinish(), onUpdate(), etc. Then this listener must be registered in all Downloads, so when a Download finishes it will call <code>listener.onFinish()</code>. Additionally I can pass parameters to this methods from the Downloads, like in the observer pattern.</p>
  
  <p>Advantage: Easily usage.
  Disadvantage: None.</p>
  
  <p>I will probably use a callback because in my opinion it makes no sense to use an observer pattern for 1 observer N observables.</p>
  
  <p>And you, which option will use?</p>