The book CleanCode recomments to sort functions by their call order:
If one function calls another, they should be vertically close, and the caller should be above the callee, if at all possible. This gives the program a natural flow.
I would like to include that order in my cleanup routine. The following example
public void content(){
primary();
secondary();
}
private void secondary(){
}
private void primary(){
};
should be automatically reordered to
public void content(){
primary();
secondary();
}
private void primary(){
};
private void secondary(){
}
(This is not the alphabetical order and primary() and secondary() have the same modifiers.)
However, I could not find an Eclipse feature doing so. Eclipse just seems to be able to sort members by their type and not by their usage.
Is there a default feature that I missed or an additional Eclipse plugin that I could install?
(I am not looking or an outline view that provides that order. I would like to change the actual order in the code. This question is not about the pros and cons of changing the code this way.)
Related article:
How to specify the order of class members when formatting in Eclipse
Thanks to the comment of ProgrammersBlock I found this plugin in Beta status:
http://wiki.eclipse.org/Recommenders/CleanCodeMethodSorter
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With