Steve Chambers Steve Chambers - 1 year ago 82
Java Question

Should a worker method generally be placed above or below the methods that call it?

Are there any conventions as to whether a method called by another method should generally be above or below it? E.g. say

was refactored into two methods - where would be the more standard place out of

private void aboveCaller() { /**/ }

public void caller() {

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).

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download