Friday, 5 December 2014

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.

Saturday, 29 November 2014

Survey results and my own findings: timestamp vs DateTime (PHP)

G'day:
Apologies for the delay in getting back to this survey ("PHP: a survey about date data handling") - although I'm sure few people would have been waiting with bated breath - I've just had a very busy week with one thing and another. Now it's Saturday and I have a moment or two to breathe before finding a pub to watch the rugby (England v Aussie and/or Wales v South Africa, which are on simultaneously).

Anyway... here are the results:

Friday, 28 November 2014

Local scope bug (or not, if you're the ColdFusion Team)

G'day:
I just spotted this, and decided to look into it:

This defines a bugsituationbug in ColdFusion wherein if one deletes a local-scoped variable from a function, then assign an unscoped variable, that new variable goes back in the local scope, not in the variables scope.