title: JavaFX - Observable Collections in the data model classes
body: <p>Here follows a simple piece of JavaFX code, to illustrate my question.</p>
  
  <pre><code>List list1 = new ArrayList();
  list1.add("foo");
  ...
  
  someListView = new ListView&lt;&gt;();
  ObservableList someObservableList = FXCollections.observableList(list1);
  someListView.setItems(someObservableList);
  ...
  
  someObservableList.add("bar");
  </code></pre>
  
  <p>If I understood correctly, after calling the <code>setItems</code> method, not only will the content of the list be shown in the <code>ListView</code> Gui component, but also if items are added to the <code>ObservableList</code> instance afterwards, the <code>ListView</code> will be refreshed automatically and will show the newly added items automatically, without the need to call any additional <code>add</code> or <code>refresh</code> methods.</p>
  
  <p>So far, so good. But what if I add something to the original list (i.e. <code>list1</code>). These changes are not propagates automatically. It makes perfect sense, but it is inconvenient sometimes.</p>
  
  <p>Of course, in a classic Java application the Model of the application does not consist of <code>ObservableCollection</code> instance. So, whenever you add something to the model, you will always have to update the <code>ObservableLists</code> instances that were derived from the original list. Apparently this is inevitable, right ?</p>
  
  <p>This got me wondering, is it a clever idea to modify <code>Collection</code> type occurrences (e.g. <code>List</code>, <code>Collection</code>, <code>Set</code>, <code>Iterable</code>, ...) in the Model classes and replace them by their <code>ObservableCollection</code> alternatives from now on ?  </p>
  
  <p>Until now I always figured that these <code>ObservableCollection</code> classes were only supposed to be used in the Gui layer of the applicaiton, but it seems pretty convenient to use them about everywhere.</p>