ColdBox I'd like you to meet Demeter
Here's a clip of code from the main component (coldbox.cfc) in the ColdBox framework:
<cfif cbController.getDebuggerService().getDebugMode() and event.getValue("debugPanel","") neq "">
<!--- Which panel to render --->
<cfif event.getValue("debugPanel") eq "cache">
<cfoutput>#cbController.getDebuggerService().renderCachePanel()#</cfoutput>
<cfabort>
<cfelseif event.getValue("debugPanel") eq "cacheviewer">
<cfoutput>#cbController.getDebuggerService().renderCacheDumper()#</cfoutput>
<cfabort>
</cfif>
</cfif>
The lines in question in particular are #cbController.getDebuggerService().renderCacheXXX()#.
It's the sort of thing most people don't think twice about, but it's a bad habit to be in... Generally speaking it would be a lot better to be in the habit of having written this so that either the coldbox.cfc contains its own getDebuggerService() method to be used here (in place of cbController.getDebuggerService()), or its own private renderCachePanel()/renderCacheDumper() methods... or both. They're not mutually exclusive of course...
Why? In principal coldbox.cfc in this case knows too much about the debugger service. Yes I know it's the ColdBox debugger service, yes I know it's not referenced in many places and yes I know it works. It's not about working or being small (which is a slippery slope), it's about habits. If you're in a habit of writing code this way, then you'll tend to write code this way even when it will bite you in the ass later.
Meet my friend Demeter.

There are no comments for this entry.
[Add Comment]