Can Whitespace Indicate Code Organization?
Have you ever tried turning off whitespace suppression and just looking at where the whitespace shows up when you view the HTML source? I’m referring to tags like cfsilent, cfsetting, functions like trim() etc. If you have a chance, try commenting out those tags and viewing your html source.
Of course we want to suppress the whitespae in a production app, but while developing it can be a useful tool. It recently occured to me that whitespace may be an indicator of code organization or disorganization.
Whitespace shows up whenever you use <CF> tags. So if you have a particularly complex <cfquery> that has 20 lines of SQL, it will show up as 20 lines of whitespace in the HTML source.
It seems to me that when an application properly separates Model, View and Controller code, then whitespace should should be at the beginning of the html source before any HTML tags are displayed. There may be a few short bits of whitespace in the HTML when tags like <cfoutput> are used. But big chunks of whitespace may mean you’re mixing model code with view code. For example if you put a <cfquery> on the line before a <cfoutput> you’re likely to have a big chunk of whitespace.
Granted, the world isn’t going to come to an end if this occurs. Although it might mean the overall application could be better organized so it’s easier for other developers to understand. Or it may mean you fell asleep on the ENTER key.
***Come to the Frameworks Conference and lets discuss this over a couple of beers***
