Monday, 6 May 2013

PHP: Getting PHPUnit up and running

G'day:
Before I write too much PHP code, I want to get my TDD environment sorted out. Prior to my current job, I'd never done unit testing before (cringe), but I'm well onboard with it as a concept. Initially it seemed arse-about-face to write tests for code that doesn't exist yet, but it really is a good approach to writing solid code, and not going to OTT with features one doesn't need (or doesn't need yet), as it makes for more testing before the unnecessary code gets written. And much as I'm OK with writing tests, I only want to write what's necessary.

I have to admit that for my after-hours work I only write unit tests for about 50% of it, and I generally write them afterwards. Mostly due to slackness, and mostly due to not really caring whether my code for this blog and other things I potter around with works robustly. But any work I do for paying clients gets written in a correct TDD fashion. And they get charged for it, and they're happy with doing so. I hasten to add I do very very little paid-for work in a "moonlighting" capacity, indeed have not accepted any for a coupla years now.

Sunday, 5 May 2013

What I plan to see @ cf.Objective()

G'day:
Apropos of not much, here's how my thoughts on what I intend to go see @ cf.Obejctive() are currently falling together. All, obviously, subject to change.

Weds

Alex and I won't be getting in to MSP until around midnight (ie: at the end of Weds), so I'll be missing all the pre-conf socialising, unfortunately. Because I lack common sense and good judgement when it comes to whether or not it's an appropriate time to have a beer, I might sniff around to see whether anyone is still propping up the hotel bar. Although I will have just got off 10h of flying, and my brain will be saying "it's 6am", so I dunno. We'll see.

Saturday, 4 May 2013

Code Review

G'day:
I became aware of Stack Exchange's Code Review website a few months back, but never really looked at it until today. I decided one way to get someone other than Bruce (no offence! ;-) to look at my PHP code would be to chuck it up there and see what happened. Well so far nothing has, but it's the weekend etc, so perhaps people have better things to do than review my code on the weekend. How this can be true I don't know, but the world is a funny place.

Anyway, they have a ColdFusion / CFML channel too, so it might be a place to chuck yer code up there to get reviewed.

Follow-up to "Quick Code Puzzle" article

G'day:
I'm a bit disappointed that I only got three responses to my code puzzle the other day, but so be it. At least Matt, Dale and Winston will get a beer next time I see them. Thanks guys: I really do appreciate you taking the time to join in.

Bruce: cheers for your response, but you didn't actually post a solution, so you weren't in the running for a beer!

To recap, the problem was to write this function:

boolean function isWithinWebroot(required string fileSystemPath){
    // provide code here
}

Friday, 3 May 2013

PHP: solving a real problem

G'day:
As you might have read, I discovered PHP has an internal web server, just like CF does. It seems a lot more basic than ColdFusion's one... especially the one that CF10 uses which is pretty much production-quality.

One thing I have not been able to find out how to do is to get it to list the contents of a directory, as one can enable on Apache / IIS etc. I'm pretty sure it doesn't support this functionality at all, as the docs mention a few options, but not that.

Thursday, 2 May 2013

cf.Objective()

G'day:
In a surprise move... I am going to cf.Objective(). So that's quite cool. My mate Alex Skinner is heading over from Blighty too, and he convinced me to tag along. The lads (and guests) from CFHour also had a hand in convincing me I really ought to make it, as the presentations people described they're giving sound excellent.

Wednesday, 1 May 2013

Quick puzzle: is this path within the doc root?

G'day:
Here's a code puzzle question.

Write a function thus:

boolean function isWithinWebroot(required string fileSystemPath){
    // provide code here
}