Some might like to argue that this is a candidate for the least important issue of all times. Yet code style is a very important topic for me, and I want to ensure that I write code in a readable way - for me and the majority of developers.
That's why I'm wondering where you guys are declaring your inner classes.
I'm following the following method ordering scheme, because it is quite common:
public void foo() {
usedByFoo();
}
private void usedByFoo() {
}
public void bar() {
}
I order them from top to bottom, every method as close to where it is used.
Now I could do the same with inner classes, like this:
class Outer {
private Inner inner;
private class Inner {};
public Outer() {
}
...
}
I think this is the most consistent style to follow for me, but I've also often seen people declare all inner classes either at the top or at the bottom of the file.
Which style should I follow, given my way of ordering methods? What is the most common way to do this?
I would declare inner-classes in the bottom of the file - usually you're not interested in their implementations and just want to get to your main class' methods, so they shouldn't get in the way.