title: API design / Command pattern vs. "normal implementation"
body: <p>I'm working on a tree-structured storage and we currently use transaction methods to modify the tree-structure. I always thought using the Command Pattern would be appropriate. However I just changed a small behaviour and I like it (returning the transaction instance located at the inserted node (except for attributes)):</p>
  
  <pre><code>wtx.insertText(EInsert.ASRIGHTSIBLING, "value").insertElement(EInsert.ASRIGHTSIBLING, new QName("bla").insertElement(EInsert.ASFIRSTCHILD, new QName("blubb")).insertAttribute(new QName("foo"), "bar").insertAttribute(new QName("bar"), "foo"));
  </code></pre>
  
  <p>I think chaining the operations this way is very nice, but our transactions provide cursor like methods on the tree (<code>moveTo(long)</code>, <code>moveToParent()</code>, <code>moveToFirstChild()</code>...) which return boolean values instead of the current transaction instance, but I think this can't be avoided. Otherwise we could even do moves between without the cumbersome </p>
  
  <pre><code>wtx.method();wtx.method();wtx.method();
  </code></pre>
  
  <p>However I thought about the command pattern which would be </p>
  
  <pre><code>new InsertText(EInsert.ASRIGHTSIBLING, "value").execute(wtx);
  new InsertElement(EInsert.ASRIGHTSIBLING, new QName("bla")).execute(wtx);
  ...
  </code></pre>
  
  <p>which is a bit more verbose but well, it would "support" the open/closed principle which is really nice.</p>
  
  <p>So, what do you think?</p>