Are there any conventions as to whether private methods should generally be placed above or below public methods? E.g. say caller()
was refactored into two methods - where would be the more standard place out of aboveCaller()
or belowCaller()
?
private void aboveCaller() { /*...here?...*/ }
public void caller() {
aboveCaller();
belowCaller();
}
private void belowCaller() { /*...or here?...*/ }
Although this is in Java, it is a general programming question and not really aimed at a specific language. (Apologies if it has been asked before - tried searching on here but didn't come up with anything).
Following the top-down design, I first write the methods calls, then implement them, so they'll be under.
Others prefer them to be above the caller since it's clearer (You first encounter the implementation, then see the call).
One thing for sure, follow your convention.