Saturday, August 21, 2010

Fluid dynamics: a code formatting experiment

Currently experimenting with fluent interface formatting. Specifically, how should you format it when you are switching context in the middle of a chain? (Should you even do that in the first place?)

System.out.println(
   new StringBuilder()
      .append("pine-apple")
      .append("apple-pie")
      .append("pie-crust")
      .toString()
         .replaceAll("([a-z]+)\\1", "$1")
         .toUpperCase()
); // PINE-APPLE-PIE-CRUST

No comments:

Post a Comment