Kev wrote an interesting article today: "Software Craftsmanship – for CFML Developers Part Six – Interlude – Passion", and I extracted a pleasing quote from it:
If you’re just a 9-5er and/or a 5 tagger [...] then do the rest of us a favour and F**K off
I needed the reorder those two clauses, but it does not alter the sentiment of the paragraph I extracted it from.
I agree with this. I don't want to be elitist about stuff, but if you only work on your craft whilst the boss is paying you (ie: 9-5), and you don't bother to try to be anything other than mediocre at your job... can you please get the hell out of the rest of our way and let us get on with it. We simply don't need jobsworth developers in the CFML community.
Anyway, this got me thinking... how many tags do I use on a regular basis? I definitely know I have never used quite a few of them: I think last time I checked I'd used about 60% of the CFML tags and about 40% of its functions. But I reckon I'm an OK developer.
I have not been in the position to write production code via a coding standard that results in code I'd be proud of for a number of years (I do not get to drive our coding standard, and it has a lot of crappy rules in it), but I am the master of my own code at home, so I did a quick survey of the code on my HDD, having first removed all the third-party libraries, and anything else that wasn't typical "Adam" code.
I knocked out this quick script to tally up the CFML tags I use:
tagTallies = {};
linesOfCode = 0;
overallTally = 0;
xmlParse(expandPath("/WEB-INF/cftags/META-INF/taglib.cftld"))
.search("/taglib/tag/name/text()")
.each(function(v){
tagTallies[v.xmlValue] = 0;
});
directoryList("C:\temp\code\", true, "array", "*.cf?", "directory, name").each(function(filePath){
var code = fileRead(filePath);
linesOfCode += code.listLen(chr(13) & chr(10));
reMatchNoCase("<cf[a-z]+", code).each(function(tag){
var tagName = tag.removeChars(1, 3);
overallTally++;
if (structKeyExists(tagTallies, tagName)){
tagTallies[tagName]++;
}else{
tagTallies[tagName] = 1;
}
});
});
writeOutput('<table border="1"><thead><tr><th>Place</th><th>Tag</th><th>Count</th><th>Percent</th></tr></thead><tbody>');
tagTallies.sort("numeric", "DESC").each(function(v){
param place=0;
if (tagTallies[v]){
writeOutput("<tr><td>#++place#</td><td>#v#</td><td>#tagTallies[v]#</td><td>#numberFormat((tagTallies[v]/overallTally)*100,'99.99')#</td></tr>");
}
});
writeOutput("</tbody></table>");
writeDump({linesOfCode=linesOfCode});
(I love the new member functions in ColdFusion 11, and especially like it when I can chain them together).
Anyway, here's the results:
Place | Tag | Count | Percent |
---|---|---|---|
1 | script | 569 | 25.50 |
2 | set | 462 | 20.71 |
3 | output | 348 | 15.60 |
4 | dump | 124 | 5.56 |
5 | function | 78 | 3.50 |
6 | loop | 59 | 2.64 |
7 | processingdirective | 49 | 2.20 |
8 | if | 43 | 1.93 |
9 | argument | 42 | 1.88 |
10 | setting | 38 | 1.70 |
11 | flush | 36 | 1.61 |
12 | return | 36 | 1.61 |
13 | param | 22 | 0.99 |
14 | component | 22 | 0.99 |
15 | savecontent | 21 | 0.94 |
16 | include | 19 | 0.85 |
17 | invoke | 15 | 0.67 |
18 | input | 15 | 0.67 |
19 | content | 14 | 0.63 |
20 | query | 14 | 0.63 |
21 | Cache | 13 | 0.58 |
22 | silent | 12 | 0.54 |
23 | else | 12 | 0.54 |
24 | lock | 11 | 0.49 |
25 | queryparam | 9 | 0.40 |
26 | chartdata | 9 | 0.40 |
27 | log | 8 | 0.36 |
28 | application | 8 | 0.36 |
29 | form | 8 | 0.36 |
30 | try | 7 | 0.31 |
31 | catch | 7 | 0.31 |
32 | xml | 7 | 0.31 |
33 | throw | 7 | 0.31 |
34 | schedule | 7 | 0.31 |
35 | document | 7 | 0.31 |
36 | import | 6 | 0.27 |
37 | location | 5 | 0.22 |
38 | http | 5 | 0.22 |
39 | break | 4 | 0.18 |
40 | file | 4 | 0.18 |
41 | header | 4 | 0.18 |
42 | dbinfo | 3 | 0.13 |
43 | tooltip | 2 | 0.09 |
44 | abort | 2 | 0.09 |
45 | exit | 2 | 0.09 |
46 | chartseries | 2 | 0.09 |
47 | chart | 2 | 0.09 |
48 | logout | 2 | 0.09 |
49 | ajaxproxy | 2 | 0.09 |
50 | thread | 2 | 0.09 |
51 | invokeargument | 2 | 0.09 |
52 | module | 2 | 0.09 |
53 | procresult | 2 | 0.09 |
54 | wddx | 2 | 0.09 |
55 | interface | 2 | 0.09 |
56 | rethrow | 1 | 0.04 |
57 | property | 1 | 0.04 |
58 | continue | 1 | 0.04 |
59 | elseif | 1 | 0.04 |
60 | storedproc | 1 | 0.04 |
61 | image | 1 | 0.04 |
62 | loginUser | 1 | 0.04 |
63 | select | 1 | 0.04 |
64 | ftp | 1 | 0.04 |
65 | login | 1 | 0.04 |
66 | 1 | 0.04 | |
67 | object | 1 | 0.04 |
68 | websocket | 1 | 0.04 |
69 | associate | 1 | 0.04 |
70 | directory | 1 | 0.04 |
71 | div | 1 | 0.04 |
struct | |
---|---|
LINESOFCODE | 25875 |
I've highlighted the tags which amount to more than 1% of the tags I use. And that'd be a huge total of 12 tags! So am I a 12-tagger? Or do I get to claim all 71?
In my defence (not that I need to defend myself!), almost all my code is written in script, other than when it would be more hassle to do so than simply use tags. But I avoid tags where I can.
If you can be arsed, perhaps run it through yer own code, and let's see what you get?
And now... time for me to head to the pub...
--
Adam