Wednesday, July 2, 2014

Private Inner / Local Classes - Advantages / Disadvantages

Good debate found here: http://stackoverflow.com/questions/3353318/how-do-i-test-local-inner-class-methods-in-java

The consensus (and accepted answer) is that in general if it's important enough for a local / private inner class to be tested, it should refactored out, e.g. to a separate package.

On the other hand, "bob" makes a good point about keeping the class internal as an implementation detail for the sake of cohesion.

Kai Sternad provides an answer that probably could have been accepted.