Following the guidelines given in "Clean Code" by Uncle Bob Martin, I'm trying to make my methods smaller.
One recommendation he gives is that methods that contain a trys should invoke other methods that don't involve the exceptional cases.
My problem is one of naming.
Usually by the time my method only contains the try expression, there's not much left and the name of the method perfectly describes what it does except for the exception.
What conventions do you use for naming the "non-exceptional" method that the exceptional one will call?
As an example, this is a method I'm looking at:
private void generateAndAttachDocumentFromTemplate(File templateFile) {
try {
File generatedDocument = generateDocumentFromTemplate(templateFile);
if (generatedDocument != null) {
attachDocument(generatedDocument, container);
attachmentsPanel.reload();
SystemControl.openDocument(generatedDocument);
}
} catch (Exception ex) {
Notifier.notifyIT(App.user().getEmail(), ex);
Dialogs.complain("Can\'t Generate Document");
}
}
I use the convention (which I think he suggests in the book) where you have methodName and tryMethodName.
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