Tuesday, 30 December 2014

A bit of fun: #Code2014

G'day:
The Hybrid Group are doing a bit of a fun Twitter survey of language usage in 2014. See here:


So go on, give it a bash.

And for the technical-accuracy-challenged of you out there (looking at you, Brad ;-), remember the language you probably use (if you're reading this), is CFML, not ColdFusion. ColdFusion is the app server (or, hopefully, Railo is the app server ;-); CFML is the language.

Anyway - ColdFusion, CFML, Cold Fusion or DBML - go have a Tweet. Support your language!

--
Adam



Saturday, 27 December 2014

Learn CFML in 24 hours: chapter 0

G'day:
I've been mulling this over since I released the CFScript docs on Github. I made a point of saying it was not aimed at teaching CFScript, it was just a reference. I then started thinking about writing a document which was a tutorial, not a reference, covering CFML. We need a decent guide to using CFML (I do not consider any of the current options to be "decent").

Thinking about it, it became clear it was going to be a non-trivial undertaking, and given my career was vacillating all over the place at the time, I pushed it into the back of my mind.

Friday, 26 December 2014

CFML: Assignments in conditional statements. Yes or no?

G'day:
I have to bang this out in 18min, as the pub is calling (it's Xmas Eve Afternoon). 17min. Crikey.

So this interesting thread cropped up on the Railo Google Group: "CFIF bug". It so transpires this compiles on Railo:

// test.cfm
a = 1;
b = 2;
if (a=b){
    writeOutput("yup");
}else{
    writeOutput("nup");
}
writeOutput("#a# #b#");

Note the typo: "=" rather than "==".

And it outputs:

yup2 2

Tuesday, 23 December 2014

JavaScript: Jasmine for unit testing

G'day:
At work, I've been tasked with getting the team up to speed with TDD whilst we redevelop our website in PHP. I knocked together a presentation on the subject a coupla months ago, but before having a chance to present it, got shifted about in the internal dept structure for a month or so, and it kinda got temporarily shelved. I posted it online: "TDD presentation". I'm back on the PHP Team now, and need to update said presentation to be more work-requirement-specific, as well as cover unit testing our JavaScript. This has been on our agenda for a coupla years, but was never allowed to get any traction by the decision makers. Decision-making has improved now, so we're all go.

I have heard about Jasmine, and like the look of it, but have never actually downloaded / installed / ran it. I'm gonna do that today.

(Oh, blogging my work is not something I do... I'm actually off on sick leave at the moment - which I feel slightly guilty about - but I need to get this stuff done, so gonna do it today whilst I am unlikely to get interruptions. I figured as I'm doing it on my own time, I get to blog about it too ;-)

I am writing about this as I do it.

Jasmine


First up: Jasmine. This is what Wikipedia has to say about Jasmine:

Jasmine is an open source testing framework for JavaScript. It aims to run on any JavaScript-enabled platform, to not intrude on the application nor the IDE, and to have easy-to-read syntax. It is heavily influenced by other unit testing frameworks, such as ScrewUnit, JSSpec, JSpec, and RSpec.
And from its own website:

Jasmine is a behavior-driven development framework for testing JavaScript code. It does not depend on any other JavaScript frameworks.

And a code sample from the same page:

describe("A suite", function() {
  it("contains spec with an expectation", function() {
    expect(true).toBe(true);
  });
});

If you're familiar with TestBox (and if you're a CFML dev, you bloody should be!), then this will look comfortingly familiar. Indeed that code would run on TestBox. I know a bit about TestBox, so this is pleasing: I have a head start!

Download & Install

I'm gonna use 2.1.3, which is - at time of writing - the latest version of Jasmine. The download page is here: jasmine 2.1.3. I've D/Led that and unzipped it into a public directory.

Running

This is too easy... it ships with a file SpecRunner.html, and browsing to that runs the tests. Here are the samples:



Nice!

Example Code

Looking at the code within SpecRunner.html, we see this:

Book review: REST Web APIs: The Book (win a copy here)

G'day:
If you're a CFML user, you probably already know that one of the cornerstone members of the CFML community - Adam Tuttle - has recently written a book "REST Web APIs: The Book". I had the privilege of being one of the pre-release reviewers - from a content and language perspective - and Adam has now asked me if I could flesh out my perceptions a bit, as a book review. I've never been asked to do a book review before. Blimey.



Monday, 22 December 2014

Weekend code puzzle: my answer (Go version)

G'day:
I sat down on Saturday / Sunday and taught myself enough Go to be able to answer the puzzle question from "Something for the weekend? A wee code puzzle (in CFML, PHP, anything really...)". I've certainly got a lot of mileage out of that one topic, eh? Oh well: I think it's a good baseline exercise for researchng new languages, and I like seeing other people's code, too. I'm so pleased I got such a good range of submissions. However it does mean it's taking me an age to slog through them all.

Right, so I discussed Adam Presley's two Go entries over the last few days: "Weekend puzzle: Adam Presley's answer (Go)" and "Weekend puzzle: Adam Presley's answer - redux (Go)", and I did a "G'day World in Go" exercise in prep for understanding his code. Not that a "G'day world" exercise was sufficient for that, but at least I got Go installed and compiling, and located the docs etc.

Sunday, 21 December 2014

Weekend code puzzle: Adam Presley's answer - redux (Go)

G'day:
Adam Presley is a bit of a star. I had a look at his original entry to the code puzzle and decided I didn't like it as it was too long-winded ("Weekend code puzzle: Adam Presley's answer (Go)"). He's subsequently come back to me with a simplified version, listed on his own blog: Response To Adam Cameron's Code Review. He took my comments in good grace, which is very good of him.

Let's have a look at this new version:

Thursday, 18 December 2014

Book review: Adam Tuttle's newest book

G'day:
Adam's been busy recently. You'll've heard about his new book "REST Web APIs: The BookREST Assured: A Pragmatic Approach to API Design" which is being released soon - I'll have a review up and a competition to win a copy next week - but he's also released the first book dedicated to ColdFusion 11's newest marquee feature: CFClient.

I know I have derided CFClient a lot, but it does have its good bits, and Adam has worked through them all and put a fairly accessible book together. Granted it's not very long, but for something that focuses on a single tag, I think that's fair enough. It's free and open source, so you should go get it, and give it a read. It might make you think again about whether or not to use CFClient. I have to admit it did give me pause for thought.

Go grab it from it's official website now (it's just a PDF): "CFClient The Good Parts".

I think Abram Adams (of trycf.com fame) said it best in his review when he said:
I felt like I was looking into the minds of Adobe engineers
It's exactly this attention to detail Adam Tuttle captures in this latest book.

CFML doyen Mark Drew had this to say:

I have been looking everywhere for an in-depth look at the useful features of the cfclient tag and I have to thank Mr Tuttle for providing it!

I am not good at reviews but I should say that this is not only The Good Parts, it is also the definitive guide.

5/5


I'll get back to you about the REST book next week (here it is: "Book review: REST Web APIs: The Book (win a copy here)"). The CFClient book'll keep you going until then.

Cheers.

--
Adam

Wednesday, 17 December 2014

Fixing CFScript: CFLDAP

G'day:
This is the first in a series of brief articles I'm going to write to demonstrate how Adobe (and, for that matter, Railo) could have implemented functionality that was formerly the preserve of tags in CFScript. The first (mostly random) example is <cfldap>. I have picked <cfldap> because someone mentioned it on IRC the other day. And I hated the advice I had to give them by way of implementing their needs in CFScript.

The problem CFML developers are faced with is that both Adobe and Railo are eroding the quality of the CFML language by implemented cross-cutting "generic" solutions for shortfalls in CFScript functionality, rather than addressing each piece of functionality professionally and thoughtfully.

Railo have implemented a generic solution which the CFML Advisory Committee came up with, years ago. The basic model is this:

Hands up: who has issues accessing the ColdFusion bugbase?

G'day:
There is a continuing issue with access to the Adobe ColdFusion bugbase: when clicking on a link (like this one: https://bugbase.adobe.com/index.cfm?event=bug&id=3909712), many many people get one of two things:

  1. redirected to a login page (that URL requires no login, so that is invalid);
  2. put into a perpetual redirect loop between ticket and login page.

I think other people have different symptoms too. And a select few actually get to see the bug. 75% of the time, I cannot get to the bug page unless I use an incognito page. Sometimes if I clear my adobe.com cookies I can get in without an incognito window, but often I still can't.

Adobe are looking at this (our man Kapil is the star there), but they cannot replicate it. This gobsmacks me, TBH, as so many people seem to have issues.

Do me a favour will you? Go click on that bug URL above, and post back what you get? Do you go straight to the ticket (lucky bugger), do you have to login? Do you get into a redirect loop? Something else? If you could let me know your OS, browser (/version) etc, that might help. If you can't get in initially, but blow awway your Adobe cookies, does that help? Anything relevant, really. If you're happy to liaise with Kapil directly, please let him know on Twitter: @KaroraKapil.

Cheers for your help.

--
Adam

PS: oh and vote for that bug, will you? Cheers.

Weekend code puzzle: Adam Presley's answer (Go)

G'day:
At long last, I'm continuing to look at each person's submissions for the code puzzle ("Something for the weekend? A wee code puzzle (in CFML, PHP, anything really...)"). There's been a bit of a hiatus because I've been busy with other things, plus generally not that interested in keeping up with this blog. Oops.

OK, so Adam's effort is in Go. The github repo for it can be found here: https://github.com/adampresley/adamCameronCodeChallenge201411.

G'day World in Go

G'day:
I've got an odd situation at present... I have a suspected lump on the inside of my eyeball, underneath my retina. I say "suspected" because the symptoms I have are those that I've had before with my other eye, and "a lump" was what it turned out to be. The manifestation of this lump is that I have a "dull" patch in my vision, caused by the light hitting the wrong part of my retina where the lump is, and my brain not quite being able to adjust for it. I'm in the NHS waiting list to get it seen to, but that's not until Dec 31. Last time the treatment was some pills, so I hope it's the same again, rather than it being like something from Un Chien Andalou. Anyway... I'm telling you this because currently I am off work due to only being able to look at a screen for a few minutes at a time, before my head starts hurting. The dull patch is to the immediate right of my focus when reading, meaning the word following the one I am currently reading is "greyed-out". Frustrating as f***.

I'm finding this jolly tedious, have decided to try to write something today, to check how long it is before I need to give up. Hopefully it'll also give my brain some training to work around the dull patch. In my vision, I mean.

So - other than the fact I'm already at the 250-word mark with completely off-topic nonsense (what is this? CFHour? ;-) - here's a short article on my experiences of getting Go up and running on this box. it's very straight forward, and this article really only serves to demonstrate how straight fwd it is, so as to perhaps give people encouragement to try it out.

Tuesday, 16 December 2014

F***ing StackOverflow. And new vs createObject() vs entityNew()

G'day:
I was typing this response on Stack Overflow, and just as I was finishing, the question was closed and I was unable to save it. What a bunch of pricks the rule-makers on StackOverflow are.

I'm not having my work wasted, so I'm publishing it here instead.

Obviously any thoughts or elaborations are welcomed.

Monday, 15 December 2014

Say "no" to Adobe and their bloody stupid generic CFScript syntax

G'day:
Firstly, sorry this blog has been a bit of a non-event recently. There's various reasons for this - none of them interesting - but I'll get back on form soon. -ish.

Now. Frickin' Adobe.

Tuesday, 9 December 2014

ColdFusion 11 update 3 and ColdFusion 10 update 15 are out

G'day:
Adobe have finalised ColdFusion 11's update 3, and ColdFusion 10's update 15. Official word is on their blog "ColdFusion 11 Update 3 and ColdFusion 10 Update 15 are available now".

I'm in the process of running them now...

ColdFusion 11 updates to version 11,0,03,292480. It claims to fix 195 issues, btw. That's pretty impressive. Although, equally, not before time.

The update installation process went smoothly (I am just running the Express install).

ColdFusion 10 updates to version 10,0,15,292549. It just mentions a security update.

Note: both updates require reconfiguring the web server connectors. As I'm just running the internal web server on both of these, I've not needed to bother with that.

I'll probably go ahead and install Java 8 now, and reconfigure these CF instances to run atop of that.

Adobe have done a good job with their fixes for ColdFusion 10 and 11 recently. However they need to reduce their cycle duration down to 2-3 monthly minimum. Once a month would be better. They don't need to fix 195 bugs every month, just the most recent ones, and a few of the longer standing ones each time. Here's hoping they can achieve this.

But: good work, Adobe. Nice one.

--
Adam

"George", eh?

G'day:
So I heard the first mention of Railo 5 in quite a while from the Railo guys today, an oblique reference from Micha:

In George (Railo 4.2 successor) the release date is set by the build process in the default.properties file, the location for this information has moved because this file is common practice with OSGi.

Two things interest me:

  • things have been very quiet re Railo 5George recently, after a lot of initial chatter about it;
  • odd to describe it as "Railo 4.2 successor" when previously they've been very open about referring to it as "Railo 5". Dunno what to make of that. I might just be reading too much into casual words on a Google group.


Anyway, it's jolly good to hear mention of it. I just bloody wish they'd hurry up and release the damned thing. At least to a public beta or something! It sounds like it's really going to be a great step forward for CFML, and will probably give Adobe a bit of a fright, I reckon.

Can't wait!

--
Adam


PS: thanks to John Whish for helping me get this article up onto coldfusionbloggers.org, which I cannot access from this machine @ present, for some reason.

Friday, 5 December 2014

(CFML) Survey results: how you write your function signatures

G'day:
Firstly, hey thanks to everyone who filled the survey in! I got over 100 responses within the space of a coupla days. That's the fastest I've had responses to a survey. Cheers!

Anyway, what did you have to say?

Adobe's most valuable employee

G'day:
No messing around: it's Anit:


TBH, I have not even checked which ticket Anit is following up on here, I'm just focusing on this bit:

#idontgiveup

And Anit doesn't. No matter what gets thrown at him. He works to help his (ColdFusion) community. No excuses, no "closed/cantbearsed". Anit just cracks on and gives us the answers.

Almost everyone else on his team could draw a page from Anit's book when it comes to client support.

Anit: thanks dude,

--
Adam

Wednesday, 3 December 2014

(CFML) It's time to get query of query improved

G'day:
I'm sure all this has done the rounds before, but I cannot find the tickets. So I have raised them again:

Tuesday, 2 December 2014

For Andy Allan

G'day:
I have no idea why I'm doing this, but here you go Andy: a blog article.

--
Adam

(CFML) A quick survey about how you write your function signatures

G'day:
The subject kinda says it all. I'm just curious as to how people tend to code their function signatures, so I'm running a short survey.

Update:

The survey is closed: Survey Monkey will only allow me to gather 100 responses, which I've now got.

Monday, 1 December 2014

Hammers and screws (and when not to use a list in CFML)

G'day:
I hope Salted (/Ross) and Ryan don't mind me pinching our IRC conversation for a blog article, but... well... too bad if they do. It's done now. This is it.

Ross was asking "whats the most efficient way to remove the first two items in a list and get back the remainder", which made my eyes narrow and decide there's probably something to get to the bottom of here. Because he mentioned "lists". And these should - in general - be avoided in CFML.



After some back and forth with Ryan, Ross settled on:

listtoarray(foo," "), arrayslice(bar,3), arraytolist(bar," ")


(pseudo code, obviously).

Now... I think lists are overused in CFML, and - indeed - they are a bit rubbish. Having a string of data and then using one character (OK, or "some characters ~") from the string as a delimiter is seldom going to work, especially with the default delimiter of comma. Because in really a lot of situations, commas are actually part of the data. And same with any other char-based delimiter (except say characters specifically intended to be delimiters like characters 28-31 (file, group record and unit separators, respectively). I really don't think lists should generally be part of a solution to anything.

With this in mind, I decided to check what was going on. This is copy-and-pasted from the IRC log (spelling and formatting addressed, otherwise it's unabridged):

16:36 <adam_cameron> Salted: first question that should be asked... why is it a list in the first place? Do you have any control over it?
16:36 <Salted> no, it's returned from a postcode lookup service
16:36 <Salted> I'm fairly certain that the address string will always have the postcode first so [p1] [pt2] [line1]
16:37 <Salted> it's not a list its a string but I'm treating it as a space delimited list for these purposes...
16:37 <adam_cameron> so it's a string? Not a list per se?
16:37 <adam_cameron> ok
16:37 <Salted> indeed
16:37 <adam_cameron> So what you actually want is everything after the second space?
16:37 <Salted> essentially yes
16:37 <adam_cameron> Not a list with the first two elements dropped off
16:37 <Salted> in this instance what you've mentioned is one and the same, if I treat it as a list
16:38 <adam_cameron> well literally, yes. However once you start treating it as a list, you're thinking about it wrong
16:39 <Salted> I don't see how thats different from thinking of strings as char arrays, for example
16:40 <Salted> "my name is ross" is both a char array of 14 elements and a list of 4 elements
16:40 <adam_cameron> because you start trying to use list functions on it
16:40 <adam_cameron> Which makes your code shit


My point here - one that Ross doesn't entirely agree with - is that just because one can use a string as a list, doesn't mean - semantically - it is a list. And one should try to keep one's code as semantically clear as possible.

What Ross has here is not a space-separated list. Later in the conversation I extracted form him what the actual data was like, and this was a sample:

X1 2YZ Apartment 1903, 10 Random Street Suburbia, OURTOWN


What we have here is... a mess. It can be assessed in a number of ways:

  • a post code part followed by an address part
  • a post code followed by a street address followed by a city
  • a post code followed by the street part of the address, the suburb part of the address, and the city part of the address
But what it isn't is a space- (or comma-, or anything-) separated list. So one should not solve this problem using lists.

One should look at the actual requirement, and solve that.