Thursday, 30 January 2014

Underlying Java methods of CFML objects

G'day:
A week or so ago, I wrote an article 'Using "undocumented" methods'. This got mention on CFHour last week: "Show #206 - Mucho Happy Box", and one observation I think Scott made was that it'd be useful to know what methods were available, even if one might not necessarily want to use 'em (see the earlier article and its comments as to why one might not want to use 'em).

Anyway, ages ago I came across a handy Java class, ClassViewer, which enables one to inspect the underlying methods of CFML objects using Java reflection. I wrote an article about it "ClassViewer.java", and posted the source code. I hasten to add it is not my own work, but it is jolly handy code. I also knocked together a CFML version of it: "ClassViewer.cfc" (Gist). I've gone through a pumped a bunch of CFML objects through this, and saved the output on my CFMLDeveloper account. Here's links to 'em all:


Wednesday, 29 January 2014

CFML: To that 20% of you out there: what the f*** are you thinking?

G'day:
I am utterly gobsmacked. Look at this:



These figures are from the intermediary results of the "State of the CF Union survey 2014" survey that's on currently. it's a trimmed version of the full results, which one can see if one completes the survey.

A few people in the community - including myself - have expressed derision at this:



SET ARITHABORT

G'day:
Hey, we've got a problem with a stored procedure we're running. When running it in SQL Server Management Studio it runs like lightning. When running it over a JDBC connection, it takes over a minute.

Our DB Manager has tracked this back to being down to a settings difference between the JDBC driver and SSMS... the latter has SET ARITHABORT=ON, and JDBC by default has it OFF.

Does anyone know how to pass these settings on the JDBC URL to set it ON? Or any other way of doing it?

Cheers for any suggestions.

--
Adam


Enhancement suggestion for parseDateTime()

G'day:
A quick one. parseDateTime() is used for taking a string and trying to convert it into a date object (as reflected by the date represented by the string).  It does a pretty shocking job of it, as demonstrated by the following code:

CFML: Bug(s) in ODBC-date/time formatting functions

G'day:
Whilst testing some TestBox glitches (more about that in a later article, but the executive summary is "it's good!"), I noticed some dodgy behaviour in the ODBC-date/time-formatting functions. In both ColdFusion and Railo.

TBH, I have no idea why we are using createOdbcDate() in our codebase at all... we do not use ODBC drivers. And that'd be the only time one would want to use these functions. Equally, they're only really useful if one wants to pass dates to DBs as strings, hard-coded into the SQL statement, and this should be actively discouraged in favour of passing parameters; and for that a native CFML date/time object is fine.

Firstly... what the hell are these functions for? (that's rhetorical... I'm about to tell you...) ODBC defines a string format one can use to unambiguously represent a date value. The details are in the Microsoft docs: "ODBC Datetime Format", but a summary is this:

{ literal_type 'constant_value' }
literal_type
Specifies the type of the escape sequence. Timestamps have three literal_type specifiers:
d
date only
t
time only
ts
timestamp (time + date)
constant_value
Is the value of the escape sequence. constant_value must follow these formats for each literal_type.
d
yyyy-mm-dd
t
hh:mm:ss[.fff]
ts
yyyy-mm-dd hh:mm:ss[.fff]
Note that the specification is very clear that the d is date only; the t is time only; and the ts is both.

State of the CF(ML?) Union survey 2014

G'day:
Just a quicky... I was astounded to see that the CFUnited blog is still "a thing", but it is. And they're currently running a survey entitled "State of the CF Union".

I think the survey is misnamed for where the CFML community is at these days, but - having filled it out - it's clear it's not a ColdFusion-specific thing, it's actually targeted at the CFML community as a whole.

So whether you use ColdFusion or Railo or OpenBD... go and fill it in! And spread the word about it. I know how hard it is to get CFMLers to fill in a survey, so the CFUnited bods could probably use all the help they can get.

Cheers.

--
Adam

Tuesday, 28 January 2014

Gavin is a star!

G'day:
Within minutes of me reaching out for help regarding my wee icon for the @CfmlNotifier Twitter account, me mate Gavin Pickin had sent me a number of options, more than one of which was eminently fit for purpose.

So I've picked this one:

That's pretty cool, and is fairly simple. Which suits me :-)

Currently my Twitter page is broken (Twitter are claiming responsibility) so I can't update it just yet.

Gavin: next time we're in the same place at the same time: there will be beer.

Cheers mate!

--
Adam

@CfBugNotifier renamed to @CfmlNotifier

G'day:
This is just a heads-up that I have renamed the @CFBugNotifier Twitter account to @CfmlNotifier. It will continue, short-term, to provide exactly the same status updates that it does now, but I intend to diversify it slightly perhaps. Plus I want to decouple it from the notion of "ColdFusion", as it'll have some CFML-vendor-neutral content too.

Sunday, 26 January 2014

More Git

G'day:
Another Git day today... this time I did the "Git Real" course on Code School (yesterday's article - "Two birds; one... stone" - was around their freebie intro course "tryGit").

I found today's course a bit superficial... TBH I think I learned more in the tryGit one than I did this one. I guess the things to learn about Git are more conceptual than "what one types at the keyboard", so the exercises in a Code School sort of environment will be a bit basic? It seemed more a test of whether I was paying attention to the videos, than whether I actually absorbed anything.

That said, it's given me another list of things to look at in more depth, which I'll do here. And I do think I have improved my understanding as to the mindset Git operates with, in contrast to how SVN (which I have a dozen years experience with) works. So this is valuable. OK, so I have this list of git commands to investigate further. And I'll document 'em here.

Saturday, 25 January 2014

Two birds; one... stone

G'day:
(If you got the allusion I was making in the title... you're a bad person).

OK, so two things have happened. I've been needing to get up to speed with Git for work-related purposed (we will presently - hopefully - be converting from SVN to Git), plus I also need to start participating in a coupla OS projects on Git. One of which I'm co-founder of ("ColdFusion UI the Right Way"). I do have an account on GitHub already, wherein I keep all the code metioned on this blog (and other bits and pieces): https://github.com/daccfml, however I pretty much just use that for backing-up, making-public and distributing it between my various computers. I can commit stuff and that's about it.

Also Andy Allan's recently written an essential blog article (I mentioned it yesterday, but here's the link again: "Version Control"), and this has already had some people come out of the wood work saying they don't use version- / source-control, excusing it as too hard. Nonsense.

By way of demonstration, I'm gonna work through getting Git up and running in this article. I've deinstalled all the Git stuff from my machine, and am starting again.

Friday, 24 January 2014

Promoting Andy's Blog: "Version Control"

G'day:
Make sure you read this blog post from Andy Allan: "Version Control". Especially if you don't use source control. If you know anyone who doesn't use source control: send it to them.

Cheers.

--
Adam

CFML: where Railo is better than ColdFusion

G'day:
I regularly find myself making comment about or mentioning in bug reports where Railo handles CFML functionality better than ColdFusion does. Railo undersells this stuff, so here's a list of points where Railo demonstrates itself to be better that Adobe at their own game.

The engineers are responsive

Just have a look at the posts on the Railo Google Group: those fellas Micha (Michael Offner) and Igal that regularly (and I mean multiple times daily) answer people's questions? They're the lead engineers from Railo. Now search the Adobe ColdFusion Forums for mention of Rupesh's name. Not a single post. Ever. Some first-line support dudes (who often don't know WTF they're talking about) answer occasionally. And some of the other ColdFusion team member participate once in a blue moon. But on the whole the Adobe ColdFusion Team do not help their community.

Railo is just easier to use

Ages back I wrote this "Comparing installations: CF10, Railo and OpenBD". To even install ColdFusion one needs an Adobe login (and you know where your password will end up...), perform a 347MB download (thanks to Andrew, Marcin & Richard for digging that info out for me), and an arcane install process which requires over a dozen steps. To install Railo, it's a 64MB download, unzip, run. This is a significant reduction in "barrier to entry" for people wanting to try CFML. Of course if one does want to "Try CFML", Abram's got a site for that: TryCF.com (and Russ has cflive.net too). But this does not detract from the main point: Railo's easier to get hold of, and up and running.

re: "Oi! You Bloody Wankers! [etc]"

G'day:
Thanks to Andrew Myers for spotting this one. It seems even Adobe (inadvertantly) agree with this sentiment:


Right there. On the home page of their own documentation site.

Brilliant.

Cheers for giving me a smile today, Andrew.

--
Adam

Thursday, 23 January 2014

Oi! You bloody wankers! Stop using ColdFusion UI controls

G'day:
So Ray's pipped me here slightly, but fair enough cos he's done all the work so far. See his own blog article "I'm not going to tell you to stop using ColdFusion UI tags anymore...", which covers exactly the same ground I'm gonna cover here. Except he's more polite.

Wednesday, 22 January 2014

Where Railo is smart and ColdFusion is dumb

G'day:
This line of investigation stemmed from this ticket in the bug tracker: SerializeJSON turns strings that look like scientific notation into floats. The contention from Adobe as to why this can't be fixed is:

At the time of serialization , datatype information of an object is not available (cause CF is typeless) and hence knowing the original datatype and convert it according is not possible sometimes and this is one of those cases.

Tuesday, 21 January 2014

Scotch on the Rocks: which sessions am I going to? (2014 version)

G'day:
The SotR crew have got the first pass of the Scotch on the Rocks 2014 schedule posted, so I'm gonna go through what I think I might go have a look at. Obviously the schedule is still subject to change, as is my whim. Right... from top to bottom...

Monday, 20 January 2014

Expectations management: what does xmlSearch() actually search through?

G'day:
Here's an intriguing one that cropped up on the Railo Google Group the other day. Consider this code:

<!--- xmlSearchFirstExample.cfm --->
<cfxml variable="x">
<root>
    <parent>
        parent1
        <child>child1</child>
        <child>
            child2
            <grandchild>grandchild1</grandchild>
        </child>
        <child>
            child3
            <grandchild>grandchild2</grandchild>
        </child>
    </parent>
    <parent>
        parent2
        <child>
            child4
            <grandchild>grandchild3</grandchild>
        </child>
        <child>
            child5
        </child>
        <child>
            child6
            <grandchild>grandchild4</grandchild>
        </child>
    </parent>
</root>
</cfxml>
<cfscript>
    secondParent = xmlSearch(x, "//parent[2]")[1];
    writeDump(secondParent);

    childrenOfSecondParent = xmlSearch(secondParent, "//child");
    writeDump(childrenOfSecondParent);
</cfscript>

So we're grabbing the second parent node, and then from within that, getting its child nodes. What's wrong with it?

Another update regarding the cookie issue on Adobe websites

G'day:
Last week I posted this article: "Update regarding the cookie issue on Adobe websites". This related to the ongoing problem the Adobe websites have had recently wherein if one was logged into one (eg: the ColdFusion 10 docs site, the bug tracker or the Adobe ColdFusion forums), then when one hit another site one needed to log-in to, one found one's self in an endless redirection loop. And that update was just letting everyone know I was in touch with Adobe about it.

Well the good news is it's fixed.

The Adobe guys took this very seriously - perhaps too seriously as my email was CCed to the Adobe CIO at one point (she deescalated it again fairly quickly ;-) - and they seem to have got it sorted out.

So this is just a "cheers" to everyone @ Adobe who had a hand in this, and thanks for sorting it out so quickly once it got in front of you.

Righto.

--
Adam

Friday, 17 January 2014

Rakshith is mistaken about the release schedule for ColdFusion 11

G'day:

First things first:

To demonstrate a point, I am going to release this blog article with one title, post my usual Twitter status update, and ask someone to "retweet" it. Then I shall be changing the title subtly... and the title change will reflect the title I actually want the article to be seen as. This is to demonstrate that once someone says something on the internet, it stays said. The original title was unfairly harsh, and a slight overstatement (although not actually inaccurate). By design.

Today I wondered out loud on Twitter whether the ColdFusion 11 pre-release lifecycle seemed longer than usual. Brian Klass set me straight on that:

And, indeed, having done some homework, I am well off base with my instinct. I'll get to that. That's only tangential to what this article is about.

Thursday, 16 January 2014

Outage on CfmlNotifier

G'day:
I actually meant to post this when it actually happened: yesterday or the day before yesterday whenever it was. It's been a busy week. Anyway, there was an outage on the CfmlNotifier feed. It's now resolve.

Unexpected writeOutput() and <cfoutput> difference

G'day:
Sorry, mentioned this on Twitter a few days ago now:


...but not finding any time for writing at the moment. I'll make a start, and see how far I get.

Weirdness with <cfflush>

G'day:
I've found a weird thing... <cfflush> doesn't always seem to work. I don't mean the old "yeah, it doesn't work in custom tags" trope (or variations on that theme), I mean... with the same code, it will work on some CF installs, and will not on others.

By the pricking of my thumbs, something ColdFusion 11 this way comes...

G'day (and apologies to WS):
This appeared in my Twitter in box over night:


Hopefully this means we might be graced with a public beta of ColdFusion 11 presently. Anyone else heard any rumours or noticed any action on this?

--
Adam

Wednesday, 15 January 2014

Update regarding the cookie issue on Adobe websites

G'day:
If you're a regular on more than one of the Adobe main website, Adobe ColdFusion forums, ColdFusion bug tracker and/or a contributor to the Adobe ColdFusion 10 documentation site, you'll be aware there's an issue with how Adobe handles cookies between their sites, and how it f***s everything up when you try to login to one site having already got a cookie from another one of their sites.

Monday, 13 January 2014

Using "undocumented" methods

G'day:
Today, my mate Duncan is my muse. That comment should make him feel pleasingly uncomfortable.

Dunc was revisiting some code, and he saw something along the lines of this (disclosure: it was my code):

numbers = queryNew("id,number", "integer,varchar", [[1,"tahi"],[2,"rua"],[3,"toru"],[4,"wha"]]);

while (numbers.next()){
    writeOutput("#numbers.id[numbers.currentRow]# #numbers.number[numbers.currentRow]# <br>");
}

Friday, 10 January 2014

ColdFusion 10 Update 13: "This update introduces support for OS X 10.9 Mavericks"

G'day:
Just a heads-up for you Mac users out there who have been caught out by issue 3653076 "Bad apache / tomcat connector for Mac OSX Mavericks 10.9".

Adobe just posted this: "ColdFusion 10 Update 13 released", and this includes the fix for the Mavericks thing.

I have not attempted to install the updater yet. Let us know how you get on with it.

Update:

I have now. Please note that the fix for 3653076 is the only fix in this update. Which is pretty bloody disappointing, actually!

--
Adam

Random thought: decoupling transaction from tag-like syntax

G'day:
This one keeps popping in and out of my mind, and I've forgotten to ask about it for about a year now. It's about how the CFScript transaction construct mimics the tagginess of <cftransaction>. And whether it needs to / should do...?

Thursday, 9 January 2014

Suggested trivial changes to the Adobe ColdFusion bug tracker

G'day:
This is more just a list of stuff for Rakshith's attention than anything relevatory. There's a few small tweaks to the bug tracker which would be useful.

Tuesday, 7 January 2014

CFML: Results of survey about function expressions in tag-based code

G'day:
A few days ago I opened a survey, "A quick survey about tags & script in the same statement" (it's still open, so go have your say if you haven't already: I'll update the results posted here). This was in response to a comment from Rupesh:

I am questioning whether this syntax can cause confusion

The syntax in question relates to being able to use function expressions in tag-based code, eg:

<cfset c = function(){ 
    var a = something;
    var b = foo();
    return a * b;
}>

I contended that was pretty bloody patronising, and I doubted anyone who was going to be using function expressions would be thrown by this sort of thing.

Still... what do I know? And I decided to poll my readers to see what they thought.

Now I get that no survey I run on this blog is going to be statistically meaningful, due to the way demographics work, and how low my readership is, and accordingly how few responses I get. But I figured in this case it might be slightly more representation of the audience for this question because stuff like function expressions is probably going to be limited to the more... erm... "engaged" people in the CFML community, and not that I reach out to all of them, but the people who take time to read blogs are going to be part of that "more engaged" demographic.

So, anyway, I was hoping for 50+ responses before I reported back, but the news is getting "stale" now, and I seem to have stalled on 49 responses. Near enough.

@CfmlNotifier and untriaged bug count

G'day:
Just a quicky. Scott and Dave had a bit of a strop at me today on CFHour: the "annoying Twitter accounts" reference in the show precis is a reference to @CfmlNotifier Twitter account. Which they don't like.

ColdFusion: Participate in your community

G'day:
One of the things a lot of the ColdFusion community members could do to improve things is... lift their game when it comes to being part of the community!

There's been a coupla examples over the last few days of this sort of thing:

Bug 3678476
Title
Few Image functions are not shown in the Coldfusion image functions list

Description
http://help.adobe.com/en_US/ColdFusion/10.0/Developing/WSc3ff6d0ea77859461172e0811cbec12207-7ffd.html#WSc3ff6d0ea77859461172e0811cbec12207-7ffa

This URL should contain the below image function:
ImageGetIPTCMetaData
ImageGetEXIFMetaData

Rupesh commenting against bug 3678093:

cfloop does have a charset attribute which is used for reading the file. however this is missing from the documentation. This needs to be documented.

(my emphasis)

From Twitter:

(and even once I fixed this one, conversation continued as to how (not) good my fix actually was!)

But in all three examples the person writing is correct.

And all three examples are now fixed. Why? Because I just went in and bloody fixed them.

Friday, 3 January 2014

Help me understand how a CFML REST request should not cause onCfcRequest() to fire

G'day:
I have to admit I am not very au fait with the idiosyncrasies of REST requests. To me a REST request is just... a request. The difference being the mechanism at the other end is more likely to respect verbs other than GET and POST like normal browser-based requests make, and they return "data" rather than mark-up. But other than that: there's nothing really to them. It's more a concept / strategy than anything else.

In this light, a while back I noticed that a REST request I was making didn't fire the associated onCfcRequest() event handler, as documented here: "REST requests don't seem to correctly use Application.cfc either". I duly raised a ticket: 3590745.

Rupesh has come back with this:

OnCFCRequest is meant for the requests which are made directly to the CFC - as AJAX request or directly over HTTP. For Rest request or web service or web socket requests, CFC happens to be an end point to a request (where the CFC is not explicitly invoked) and therefore OnCFCRequest is not called for these three types of requests.

I understand what he's saying, but to me - as I say in my follow-up - what he says seems like an example of post hoc ergo propter hoc. Basically the conclusion drawn is not implied by the supporting information. Here's what I said in response:

Thursday, 2 January 2014

A quick survey about tags & script in the same statement

G'day:
Here's a quick survey for y'all: '"Closure" confusion'.

Update:

As one of my respondents observed... the question has nothing to do with "closure" but is entirely relating to anonymous functions / function expressions. For better or for worse, people use the term "closure" incorrectly to describe these things. A function expression implements closure, but there's no such thing as "a closure" (no matter how many people will it to be the case). Closure is not a countable noun; it's a concept. I am fully aware of this, I was just mocking Adobe's usage of the term. Hence me referring to it in quotes.

The narrative for the survey is as follows:

This is a quick survey to determine how clear some suggested CFML syntax would be. It relates to the bug tracker issue described here: https://bugbase.adobe.com/index.cfm?event=bug&id=3648781

The contention is that the suggested syntax would be confusing for CFML developers.

I am just wanting to gauge your thoughts on this.

I will collate the responses after I have received a reasonable number of them, and post them on my blog.

Cheers.

Go on, tell me what you really think...

G'day:
I touched on this in the article I just pressed "publish" on a few min ago: "Contempt of court". A while back Kev put me onto this website sayat.me. It's for people to leave anonymous feedback about other people.

It's an interesting concept, and I have opened an account there. You can whine about me all you like via http://sayat.me/daccfml.

To be honest, you should feel you can say anything you like to me to my face (or personally, without feeling the need to be anonymous). I won't take offence, and I could well agree with what you say, or we can make a discussion out of it. But anyway, some people like hiding behind electronic apron strings, so if that's you: here's your opportunity.

Whilst it's anonymous, that doesn't mean it's private. I reserve the right to reproduce anything written there. And I might even comment on it.

One thing I will say though, if you're commenting on what a baddy I am but then stoop to this sort of ad hominem:

you come across as a complete and utter asshole. [...] In short you become a unabashed prick.

Then I'm just gonna observe that you're engaging in the very thing you're deriding me for, however not having the courtesy to say it to my face.

Still: "sticks ''n stones" etc. It's not like any feedback along those lines surprises me or anything. It's just not really that constructive.

But it's great reading, so get into it.

--
Adam

ColdFusion: contempt of court

G'day:
Be forewarned. If you're the sort of person who reacts poorly to me being a meany, then can I just refer to this this right now: "Why weI fight" (and this blog's communication policy), and perhaps you oughtn't bother reading this. I do call into question someone in our community's professional capabilities here. And some of you might not like that. [shrug].

I am reproducing this here, as some of it has already been redacted by Adobe. I understand why they have done this: fair enough.

Here's an exchange in the comments (OK, not the best place for me to have posted some of this, I know) against bug 3648781: "Closures cannot be declared outside of cfscript".


Rupesh Kumar (RK):

11:02:55 PM GMT+00:00 Jan 1, 2014

It is not about half implementation at all. Outside cfscript, functions are declared using cffunction tag. Now how do you define the closures in tag syntax? The only way to do that would be using an ugly mix of script and tag which would look like

<cfset c = function(){
    var a = something;
    var b = foo();
    return a * b;
}>

To me, this syntax looks confusing. Given that more and more new code is being written in cfscript, I feel we should not mix script and tags in this way. Deferring it for the time being and we will revisit this later.

Adam Cameron (AC):

3:01:16 AM GMT+00:00 Jan 2, 2014

It's just an expression like any other sort of expression, Rupesh.

You can't say "oh, this sort of expression is OK in a CFSET statement, but this other sort of expression? No, can't do one of those". That's ridiculous.

By way of comparison, this already works fine in Railo. But then again they're not quite so judgemental/patronising as to what will / won't look "too complicated" for CFML developers.

I think if it looks complicated *to you*, you probably should not be making decisions as to what does and does not go into the language.

--
Adam

Wednesday, 1 January 2014

CFML: Using Query.cfc doesn't have to be the drama Adobe wants it to be

G'day:
Yesterday / today I was talking to me mate Adam Tuttle about the drawbacks of ColdFusion's Query.cfc, and using it. Adam's blogged about this ("Script Queries Are Dead; Long Live Script Queries!"), and written a proof of concept of how it could be better done.

This got me thinking about how bad Query.cfc's intended usage needs to be.

I'll start by saying - "repeating", actually, as I will say this to anyone who will listen - what a shitty abomination of an implementation Query.cfc (and its ilk) is. It's the worst implementation of functionality ColdFusion has. It is the nadir of "capability" demonstrated by the Adobe ColdFusion Team. Whoever is responsible for it should be removed from the team, and never be allowed to interfere with our language ever again.

But anyway.

OK, so Adobe's idea of how we should query a database via CFScript is this:

queryService = new query(); 
queryService.setDatasource("cfdocexamples"); 
queryService.setName("GetParks"); 
queryService.setcachedwithin(CreateTimeSpan(0, 6, 0, 0)); 
queryService.addParam(name="state",value="MD",cfsqltype="cf_sql_varchar"); 
queryService.addParam(value="National Capital Region",cfsqltype="cf_sql_varchar"); 
result = queryService.execute(sql="SELECT PARKNAME, REGION, STATE FROM Parks WHERE STATE = :state and REGION = ? ORDER BY ParkName, State "); 
GetParks = result.getResult(); 

That's from the docs. I'm not making that up. No wonder people think it's clumsy. Compare the above to the equivalent <cfquery>:

<cfquery name="GetParks" datasource="cfdocexamples" cachedwithin="#createTimeSpan(0, 6, 0, 0)#">
    SELECT        PARKNAME, REGION, STATE
    FROM        Parks
    WHERE        STATE    = <cfqueryparam value="MD" cfsqltype="cf_sql_varchar">
    and            REGION    = <cfqueryparam value="National Capital Region" cfsqltype="cf_sql_varchar">
    ORDER BY    ParkName
</cfquery>