G'day:
First things first: Luis, Brad, everyone at Ortus Solutions: I bloody love you guys. Working with TestBox and MockBox is an absolute pleasure compared to getting their PHP equivalents installed and working properly.
Over the last coupla weeks, meself and Duncan have been investigating unit testing on PHP, and specifically how to mock dependencies. On our old CFML code base, we have 1000s of test, and we use MockBox heavily, as we have rather a lot of dependencies which interfere with testing if they're not mocked. We only ever really moved to TestBox as a proof-of-concept before our CFML codebase was put into maintenance mode, and we shifted to PHP. Prior to that we had been using MXUnit for a number of years.
PHPUnit is a bit rough-and-ready in comparison to TestBox, but it's solid and will do the trick. However we both had an arsehole of a time getting AspectMock to work. And we both failed and moved on to other things. Earlier I'd looked at Mockery as a solution for mocking - its docs are better than AspectMock's (both a recommendation for Mockery, and an indictment of AspectMock), but it did not do something things we expect to need to be doing, whereas AspectMock claims it can (mocking static methods).
Anyway, this afternoon I found myself furrowing my brow and thought "I'm going to get that bloody thing to work... or else". Fortunately after a lot of swearing and wondering if I can hunt down and punish AspectMock's author... I finally noticed what I had been doing wrong. I presume Duncan was doing the same thing wrong, but don't know. Anyway, I got it working.
So here's my AspectMock mission from this afternoon.
Showing posts with label Duncan Cumming. Show all posts
Showing posts with label Duncan Cumming. Show all posts
Saturday, 18 October 2014
Saturday, 11 October 2014
PHP: Inspired by Duncan: palindromes via generators
G'day:
My mate Dunc is making a habit of being my muse @ the moment. I guess it's cos we're both learning PHP at the same time, and he's blogging about it as well. This morning he has a new article following his foray into translating his CFML (and Python occasionally) knowledge into PHP: "Project Euler: problem 36 (PHP)".
My mate Dunc is making a habit of being my muse @ the moment. I guess it's cos we're both learning PHP at the same time, and he's blogging about it as well. This morning he has a new article following his foray into translating his CFML (and Python occasionally) knowledge into PHP: "Project Euler: problem 36 (PHP)".
Labels:
Duncan Cumming,
Generators,
PHP
Friday, 26 September 2014
PHP: another generator example: primes
G'day:
Duncan has mused me again. He's reworking his Project Euler exercises that he'd previously done in CFML, and is now implementing in PHP. In yesterday's exercise he was looking at prime numbers: "Project Euler: problem 7 (PHP)". I thought there was scope for another exercise in using PHP generators in this for me (see previous: "PHP: generators").
Duncan has mused me again. He's reworking his Project Euler exercises that he'd previously done in CFML, and is now implementing in PHP. In yesterday's exercise he was looking at prime numbers: "Project Euler: problem 7 (PHP)". I thought there was scope for another exercise in using PHP generators in this for me (see previous: "PHP: generators").
Labels:
Duncan Cumming,
Generators,
PHP
Saturday, 20 September 2014
PHP: generators
G'day:
Duncan's my muse today. Like me, my mate Duncan has recently moved from our defunct CFML team to the PHP team. And like me, Dunc now needs to learn PHP. He's logging his progress as well, and if this sort of thing interests you (following our progress), then maybe keep an eye on what he's doing too.
Duncan's my muse today. Like me, my mate Duncan has recently moved from our defunct CFML team to the PHP team. And like me, Dunc now needs to learn PHP. He's logging his progress as well, and if this sort of thing interests you (following our progress), then maybe keep an eye on what he's doing too.
Labels:
Duncan Cumming,
Generators,
PHP
Thursday, 15 May 2014
Regarding regex: two things I'd like everyone to do
G'day:
Today my mate / colleague Duncan Cumming is my muse. But - sorry Daddy Duncky - not in a good way.
There was a question on StackOverflow over night "Need regular expression to insert a numeric value between filename and extension?". Dunc's given a reasonable answer, but also perpetuated an old trope which seriously needs to be put to rest:
The thing is... using regexes isn't that hard. Obviously one can do some incredibly complicated and impenetrable with them, but this is the same as with any technology. But I think stupid (if slightly amusing, granted) quotes like the above have gone a long way to making regular expressions seem mystical and complex to people. It's not. It's just pattern matching. They're no where near as complex as the CFML programming logic we work with every day.
Today my mate / colleague Duncan Cumming is my muse. But - sorry Daddy Duncky - not in a good way.
There was a question on StackOverflow over night "Need regular expression to insert a numeric value between filename and extension?". Dunc's given a reasonable answer, but also perpetuated an old trope which seriously needs to be put to rest:
Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems.Thanks for that, Jamie Zawinski. And also thanks to Peter Boughton for giving Duncan a smack down on this. Peter is probably the chief CFML-community regular expression guru I know. Yes: more so than Ben Nadel.
The thing is... using regexes isn't that hard. Obviously one can do some incredibly complicated and impenetrable with them, but this is the same as with any technology. But I think stupid (if slightly amusing, granted) quotes like the above have gone a long way to making regular expressions seem mystical and complex to people. It's not. It's just pattern matching. They're no where near as complex as the CFML programming logic we work with every day.
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):
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>");
}
Labels:
CFML,
Duncan Cumming,
Rhetoric
Sunday, 8 December 2013
CFML: For the sake of completeness: createLocalisedDayOfWeekAsInteger()
: a closure approach
G'day:
A coupla days ago I continued my TDD / unit testing series with an article "Unit Testing / TDD - refactoring existing code". This engendered a few comments, none of which paid any attention to the intent article, instead focused on something pretty much irrelevant to what I was discussing. This engendered this reaction from me:
Oh how I love my readership sometimes. But, actually, the comments got me thinking...
That article covered the approval process for CFLib of a function dayOfWeekAsInteger(), which is the reverse of dayOfWeekAsString(): it takes a string (in English only), and returns which day of the week that corresponds to, starting with Sunday as the first day. Why does it start on Sunday instead of Monday (as per ISO 8601)? Because it's the inverse of dayOfWeekAsString(), and that's how that does it. Is that right? Well: no. Is that relevant to either this UDF or the blog article? Also: no.
However James's suggestion for how Simon could rewrite his function to suit James's requirements (James: write your own functions if you want them different from how others have implemented them!) did get me thinking about how to do it. A thought popped into my head that one could leverage closure to create a function which was specific to a given locale. This might not be exactly what James wants, but it was what I decided to look into, because it's slightly interesting, and covers a feature of closure I've not covered anywhere on this blog yet. So it interests me.
A coupla days ago I continued my TDD / unit testing series with an article "Unit Testing / TDD - refactoring existing code". This engendered a few comments, none of which paid any attention to the intent article, instead focused on something pretty much irrelevant to what I was discussing. This engendered this reaction from me:
Bashes. Head. Against. Desk. In. Despair.
— Adam Cameron (@dacCfml) December 6, 2013
Oh how I love my readership sometimes. But, actually, the comments got me thinking...
That article covered the approval process for CFLib of a function dayOfWeekAsInteger(), which is the reverse of dayOfWeekAsString(): it takes a string (in English only), and returns which day of the week that corresponds to, starting with Sunday as the first day. Why does it start on Sunday instead of Monday (as per ISO 8601)? Because it's the inverse of dayOfWeekAsString(), and that's how that does it. Is that right? Well: no. Is that relevant to either this UDF or the blog article? Also: no.
However James's suggestion for how Simon could rewrite his function to suit James's requirements (James: write your own functions if you want them different from how others have implemented them!) did get me thinking about how to do it. A thought popped into my head that one could leverage closure to create a function which was specific to a given locale. This might not be exactly what James wants, but it was what I decided to look into, because it's slightly interesting, and covers a feature of closure I've not covered anywhere on this blog yet. So it interests me.
Friday, 23 August 2013
Kenya
G'day:
My mate Duncan did some research for me on the subject of date formats, as feedback to yesterday's article "Not every single string that can possibly be parsed as a date should be treated like a date!".
I had made this claim:
Well Duncan pointed me at this Wikipedia page: "Date format by country". Wikipedia seems to have pages for everything.
As it turns out there is a country in which the date format is "yy/mm/dd": Kenya. Who'd've known?
That said, I stand by my point. Not for the sake of pigheadedness (well not solely that ;-), but because "Kenyan" (or any approximation thereof) is not a locale that ColdFusion supports (according to the locales listed in server.coldfusion.supportedLocales, anyhow).
So in the context of CFML... there still really is no justification for ColdFusion to ever to consider the string "xx/xx/xx" as a date-parseable value representing the format "yy/mm/dd". For it to do so, IMO, is a bug: 3617365.
--
Adam
My mate Duncan did some research for me on the subject of date formats, as feedback to yesterday's article "Not every single string that can possibly be parsed as a date should be treated like a date!".
I had made this claim:
[...]there is not situation in which a string formatted as "xx/xx/xx" should be interpreted as a date "yy/mm/dd". No-one writes dates as "yy/mm/dd".
Well Duncan pointed me at this Wikipedia page: "Date format by country". Wikipedia seems to have pages for everything.
As it turns out there is a country in which the date format is "yy/mm/dd": Kenya. Who'd've known?
That said, I stand by my point. Not for the sake of pigheadedness (well not solely that ;-), but because "Kenyan" (or any approximation thereof) is not a locale that ColdFusion supports (according to the locales listed in server.coldfusion.supportedLocales, anyhow).
So in the context of CFML... there still really is no justification for ColdFusion to ever to consider the string "xx/xx/xx" as a date-parseable value representing the format "yy/mm/dd". For it to do so, IMO, is a bug: 3617365.
--
Adam
Labels:
Dates,
Duncan Cumming
Thursday, 18 July 2013
1
G'day:
I'm a bit late with this as it happened a week or so ago, but I just noticed I've been prattling away on this blog for a year now.
Apropos of nothing, here's some mostly useless information about this blog.
To close, I'd like to say special thanks to a few people whose participation in this blog has been helpful, interesting or thought-provoking. In no particular order, and it's certainly not an exhaustive list:
And now on to year 2...
--
Adam
I'm a bit late with this as it happened a week or so ago, but I just noticed I've been prattling away on this blog for a year now.
Apropos of nothing, here's some mostly useless information about this blog.
- I've "published" 322 articles; I've got 14 in progress (some of the "in progress" is just a title and an idea).
- That's an accumulation of approximately 350000 words (!!).
- I've had almost 2000 comments! Crikey, that comes as a surprise.
- According to Google Analytics (which I installed about a week after I started), I've had 25000 people visit the blog.
- My busiest day was Mon 8 April this year. That day I knocked out four articles, which helps:
- A reader asks me: "CF10 for a new start up?". Answer: no
- Moving House... Mango Blog? (note that I have not moved it yet... I'm still on Blogspot)
- Now with comments on the mobile version
- onApplicationStart() will run whilst onApplicationEnd() is still underway
- The most viewed article - by far - is the article my mate Chris wrote on his adventures getting Railo working on his Raspberry Pi! I'm not proud, so I've had a bit of a laugh with him about that. I should get him to write more stuff. The next four most popular were:
- However the most +1`ed article was one of my own: What do I want to see in ColdFusion 11?
- The most commented-on article (with 41 comments) is - surprisingly - the very non-controversial "Unexpectedly performance differences between listFind() and arrayFind() in ColdFusion"; second to that have 40 comments, and was "Which CFML-oriented blogs do you read?"
- In January this year (so after the first six months), I was averaging 94 unique visitors per day; Over the most recent six months, it's about 150 per day. So not a huge amount of traffic still, but at least it's something. And it's generally building week by week, so that's a positive sign.
To close, I'd like to say special thanks to a few people whose participation in this blog has been helpful, interesting or thought-provoking. In no particular order, and it's certainly not an exhaustive list:
- Chris Kobrzak
- Sean Corfield
- Andrew Myers
- Bruce Kirkpatrick
- Brad Wood
- Andrew Scott
- Adam Tuttle
- Ray Camden
- Gavin Pickin
- Jay Cunnington
- Simon Baynes
- Duncan Cumming
- Brian Sadler
And now on to year 2...
--
Adam
Wednesday, 19 December 2012
When functions do too much, and how to get them to do more
G'day:
After soliciting more UDFs for CFLib a while ago, I've been dead slack at processing the inbound queue, and fixing some bugs people have found. Sorry about that. I started playing catch-up at lunchtime today: you might have noticed a coupla bugfixes bubbling through on Twitter if you follow the @cfbloggers feed.
After soliciting more UDFs for CFLib a while ago, I've been dead slack at processing the inbound queue, and fixing some bugs people have found. Sorry about that. I started playing catch-up at lunchtime today: you might have noticed a coupla bugfixes bubbling through on Twitter if you follow the @cfbloggers feed.
Subscribe to:
Posts (Atom)