I do this also.
I don’t understand this argument. When you’re searching for a method you might not know whether it’s public or private so you wouldn’t know where to look. Also, when you read the code and see a method called you don’t know either if it’s public or private, until you get to its definition. And it’s not like IDEs mark on the scroll bar the place where public / private methods start. You’d have to scroll to find the method definition, which is harder than using the code navigation provided by all IDEs (Ctrl+Click on method name, class outline panel, etc.). So I don’t see how sorting the methods by access type helps you find the method definition.
For me it makes sense to sort the class fields because since they take little vertical space you can scan the list quickly, most of the time, and thus the sort can help you understand the “structure” of the class (what data is static, what data is public, etc.). I don’t see the benefit of sorting the methods because they take a lot of vertical space so you can’t easily scan the entire list of methods directly from the source file. You need the class outline for this, which makes the method order less important for scanning the source code (because the class outline doesn’t have to respect the order from the source file), so I’d prefer to let the developers organize the methods the way they want.
If you mean automatic formatting then the point is to not configure the automated formatter to move methods around. Maybe I didn’t understood, but ATM the automatic formatter doesn’t move methods around, at least in Eclipse, and you propose to configure the automatic formatter to do so.
No, because there’s no rule to sort the methods either, so I would have asked you to move the methods back. My point is that you shouldn’t re-format existing code unless there is a rule for it or you have a good reason.
Formatting long lines of code is a bit different for me. Personally I try to avoid re-formatting the code I don’t change (by selecting and formatting only the code I change). But sometimes I do re-format the long lines I change, using the automatic formatter. If there is a better way to configure how long lines are formatted then I’m OK to apply that, i.e. if you can configure the automatic line formatter to have an output that is closer to the way you manually format long lines then I’m OK to use that style. But I don’t think that formatting long lines is the same as moving methods around.
No, it’s not OK with me. I wouldn’t move methods around unless I have a good reason.
Yes.
Thanks,
Marius