Say that you have an web application which prints pages in a document. Suppose that after validating the page range, the application does the following:
If a billing option is turned on, it first checks with the server to confirm the print.
After confirming the print (or doing nothing if the billing option is not turned on), it then prints the pages.
In order to support billing being both on and off, the code looks something like this:
function printPages (...) {
if (billing) {
confirmPrintWithServer(..., function () {
printPagesInternal(...);
});
} else {
printPagesInternal(...);
}
}
If the call to check the printing was synchronous, this wouldn't really be a problem. Then it would look like this:
function printPages (...) {
if (billing) {
if (!confirmPrintWithServer(...)) return;
}
// continue with rest of printPages
}
What went in a "printPagesInternal" in the first case would simply be the rest of printPages in the synchronous case.
Is there any better way to name these two things than appending "Internal" or something similar to the end of the one that the caller of the code does not see? If we had more layers of checks, would we do "InternalInternal"? Is the "more layers of checks" situation just not going to happen, so adding "Internal" is actually the right solution?
printPagesImpl,printPagesHelper,printPagesCallback,sendPageDataToPrinter,printConfirmedPages,displayPrintPreviewPopup, etc. It depends to some extent on what the "internal" method actually does.