I think this is mainly a case of personal preference. Any performance difference is likely to be negligible.
Personally, I prefer a nested class:
- Its harder to screw
- The switch statements are ugly
- You can use local variables that may be useful.
But some people think that nested classes are ugly and therefore prefer an implementation approach. This approach works better if you have only one listener implemented in action.
Cheryl Simon
source share