Originally Posted by
Junky
My personal beliefs are that if you have a nested/inner class then the purpose of that class is to be used by (and only by) the enclosing class. If the nested/inner class DOES need to used/accessed by another class then why the hell is it a nested/inner class in the first place? It should be a top level class in it's own right.
True in general, but there are situations (e.g. anonymous Iterators, factory classes, etc.), where it just makes more sense to use an inner class that returns an interface implementation. That way, the implementation is kept private. With things like anonymous Iterators, it's a way of extending the API of the host/owner class without explicitly adding a whole bunch of methods to it.