Monday 24 February 2014

Five-tagger? what n-tagger am I?

G'day:
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:

PlaceTagCountPercent
1script56925.50
2set46220.71
3output34815.60
4dump1245.56
5function783.50
6loop592.64
7processingdirective492.20
8if431.93
9argument421.88
10setting381.70
11flush361.61
12return361.61
13param220.99
14component220.99
15savecontent210.94
16include190.85
17invoke150.67
18input150.67
19content140.63
20query140.63
21Cache130.58
22silent120.54
23else120.54
24lock110.49
25queryparam90.40
26chartdata90.40
27log80.36
28application80.36
29form80.36
30try70.31
31catch70.31
32xml70.31
33throw70.31
34schedule70.31
35document70.31
36import60.27
37location50.22
38http50.22
39break40.18
40file40.18
41header40.18
42dbinfo30.13
43tooltip20.09
44abort20.09
45exit20.09
46chartseries20.09
47chart20.09
48logout20.09
49ajaxproxy20.09
50thread20.09
51invokeargument20.09
52module20.09
53procresult20.09
54wddx20.09
55interface20.09
56rethrow10.04
57property10.04
58continue10.04
59elseif10.04
60storedproc10.04
61image10.04
62loginUser10.04
63select10.04
64ftp10.04
65login10.04
66mail10.04
67object10.04
68websocket10.04
69associate10.04
70directory10.04
71div10.04

struct
LINESOFCODE25875

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