Adam Cameron
Adam Cameron
runReport
is a bit of a god method. It's clearly doing a bunch of different things (each comment denotes "a different thing"), which rather violates the Single Responsibility Principle, as well as probably the Open-closed Principle (ref: https://en.wikipedia.org/wiki/SOLID).
What it should be doing is breaking each of those out into separate methods.
Why?
Because if I was to be wanting to extend SimpleReporter to change some of its behaviour, then I need to override that entire method. Even though - in my case - all I really want to do is to override a method that might be called prepareReport
(or something like that... I derived that from the comment in the code I pointed to above).
All I want to do is to use a different .cfm file for the mark-up, eg:
// me.adamcameron.myApp.test.reports.SimpleReporter
component extends=testbox.system.reports.SimpleReporter {
function prepareReport() {
savecontent variable="local.report" {
include "/some/different/path/here.cfm";
}
return local.report
}
}
All the config stuff the reporter does is spot-on for my requirements... I just need to tweak the output slightly.
The general design advice that "if you are tempted to put a comment in your code to explain what happens next... then that next thing should be a function with a name that describes what the comment would be describing" exists for a reason.lmajano
04/12/2022, 5:07 PMAdam Cameron
contributing.MD
getting created I guess.lmajano
04/12/2022, 5:10 PMlmajano
04/12/2022, 5:10 PMAdam Cameron
lmajano
04/12/2022, 5:10 PMlmajano
04/12/2022, 5:10 PMlmajano
04/12/2022, 5:11 PMlmajano
04/12/2022, 5:11 PMAdam Cameron
lmajano
04/12/2022, 5:11 PMAdam Cameron
lmajano
04/12/2022, 5:38 PMAdam Cameron