Activity here has ceased. A new blog has arisen: nosedog.tumblr.com. Long may it reign!
Monday, October 12, 2009
Unit testing in Ruby
Once upon a time, a Ruby programmer would more or less assume that test/unit was all there was to unit testing in Ruby. It followed the paradigm laid down by JUnit, and that was that. Nowadays, specification (as opposed to unit testing) frameworks like RSpec are all the rage. Doing some serious Ruby coding for the first time in ages, I turned to test/unit out of habit, but found it just as unwieldy as I always remembered it. It fits the way I think about unit testing (that is, create an object and assert a bunch of things). Looking for alternatives, I couldn't believe how much has changed. It seems every arsehole has their own testing framework now!
test/unit is now maintained as a gem and is having a bunch of improvements added to it. It was nearly replaced in the Ruby standard library by minitest but the author of that was too arrogant to make the marriage work. dfect has a nice minimal API and drops you into a debugger when something fails. Ara Howard, always an author of excellent libraries, created testy, a minimalist and very opinionated approach. And there are a bunch of nimble gems that tinker juts a little with test/unit (e.g. to add contexts or what have you). There's a long list to look at here.
So what have I gone with? Drumroll... test/unit! I installed the v1.2.3 gem, which is exactly the same test/unit as I left it years ago. I've also installed turn, to give nicer output, and hacked it to give even more colour.
This setup is doing well at the moment, but I've given some thought to features of my own testing framework, should it ever eventuate:
- Simple approach, like test/unit (but also look at dfect and testy).
- Less typing than test/unit.
- Colourful output, drawing the eye to appropriate filenames and line numbers.
- Stacktraces are filtered to get rid of rubbish like RubyGems's "custom_require" (I do this already with my mods to turn).
- Easy to select the test cases you want to run.
- Output like turn.
- Optional drop-in to debugger or IRB at point of failure.
And finally, although I like elements of the spec approach in theory, in practice I've never warmed to them. Before creating a framework, it would be wise to try out that approach properly, to see what aspects of it I'd like to implement.
Update: Two more features to add. Colour-coding the "expected" value (green) and the "actual" value (red) in the case of a failure (introduced in test-unit-2.0.4); code-based filter of tests to be run within the class (e.g. class TestSomething < TestCase; def filter; /789/; end; ...; end). That's easy to modify as you repeatedly run tests in that class and want to focus on the output of just a couple of them.
Saturday, September 20, 2008
In praise of record company contracts
It commonly happens that a musical artist fizzles out but is contractually obliged to provide (say) one more album for release. Usually, the artist resents this obligation and dishes up some rubbish from the vaults (Led Zeppelin's Coda, Bob Dylan's Dylan), or merely compiles a best-of.
However, I read today that two albums I value very highly – Bob Dylan's (1992) and Good As I Been To You (1992) and World Gone Wrong (1993) – were made under contractual obligation. This is not surprising, in retrospect. Not one song on them is an original composition; rather, both albums are unaccompanied acoustic performances of "traditional" folk and blues material. They were released after several albums of sludge in the 1980s with only a small percentage of good material.
Artistically, Dylan was at a low ebb and these two records were seen as a way of taking the pressure off himself and rekindling his muse, whence the rivers of rootsy gold in his three albums since: Time Out of Mind (1997), "Love and Theft" (2001) and Modern Times (2006). His early 90s efforts are curiosities, yet wonderful curiosities, and were it not for that insidious thing known as contractual obligation, we may never have received them.
Thursday, September 18, 2008
Turnbull in the Liberal leadership
So Malcolm the Money has finally gained the Liberal leadership from Brendan the Brief. This will be interesting. I've always admired Malcolm Turnbull: he has combined conventional success with public-mindedness (to wit, his leading the failed charge towards an Australian republic in 1999); his clear intellect and small-l liberal inclinations (a strongly correlated pair of qualities, in my opinion); his failure, so far, to sound like an overly conventional politician.
There's a meme out there that he has a large ego. Annabel Crabb was hilarious in the SMH recently, writing:
Accounts of the Turnbull ego do differ across the broad church of the Liberal Party.
Some argue it is Milky Way-sized, while his intimate admirers and defenders (whose ranks are fast swelling with opportunists) argue it could probably be squeezed into Wembley Stadium.
I don't doubt it for a minute, but I do doubt that he proclaims his own wisdom to the exclusion of all others. I imagine he seeks a contest of ideas from his colleagues, rather than a chorus of yes-men. Anyway, we'll see...
One thing's for sure, Rudd's going to find the going a bit tougher now. He's had an easy ride since the election; too easy. A competent, ambitious Opposition Leader can only be good for the country.
Stupidity reaches Google
Seen in Google Maps, after seeking directions:
These directions are for planning purposes only. You may find that construction projects, traffic, weather, or other events may cause conditions to differ from the map results, and you should plan your route accordingly. You must obey all signs or notices regarding your route.What kind of idiot would need to have this pointed out to them? The other 99.83% of us must now suffer this inane disclaimer, and lower even further our expectation that whatever text graces our screen is likely to be worth reading.
Saturday, August 16, 2008
Moonlight Sonata in B minor
A curiosity I heard on the radio today. Beethoven's Moonlight Sonata is in C# minor, but a recently-deceased New Zealand-born pianist insisted on playing it in B minor, a whole tone lower. Tessa Birnie apparently claimed that C# minor on a modern piano does not equate to C# minor in Beethoven's day, and that modern performers are guilty of inauthenticity.
So Classic FM played her recording of it, and it did sound very different from what I'm used to. Amazing the difference a slight change of key can make.
Another notable feature of the way she played it is that she honours Beethoven's pedal markings strictly, whereas modern interpreters say that modern pianos feature far stronger sustain than old ones, so following the pedal markings is illogical. I have to agree. Her recording sounded quite muddy a lot of the time. This was interesting, but I'm not convinced it's for the better. It's interesting how she was inconsistent in her insistence on recreating the original Beethoven experience.
Speaking just of the first movement, I'd say her interpretation is more brooding, but lacks the direct beauty of a standard modern performance. It was a real treat to hear, though.
Posted by GS at 8:25 AM
Thursday, July 17, 2008
Deus Ex Machina cafe
On Parramatta Rd in Camperdown lies an intriguing store for anyone with even a curious interest in motorcycles: Deus Ex Machina. OK, it's a motorcycle shop; big deal. But it's a very nice looking shop that emphasises the aesthetic beauty often found in motorcycles. After all, the name literally means God out of a machine.
However, fully half the building is devoted to a cafe, and it's wonderful. It's a large space with nice design and artwork. Large communal tables, designer chairs, ample sofas, huge speakers playing nice soft background music, a few vintage motorcycles around the place, good menu and prices. Altogether, it's remarkable. And despite having driven past the place many times, I was pretty much unaware of the existence of this cafe until a friend mentioned it.
The coffee (latte) had a great texture and good but not great flavour (a little sour). I'm prepared to believe that's a one-off. You wouldn't go to the effort of creating an excellent cafe without creating excellent coffee.
The icing on the cake is the reading material available. In many cafes you're lucky to get your hands on today's newspaper. Deus has about 20 back-issues of The New Yorker on its magazine table. (
After sipping and reading for quite a while, I wandered through to the motorcycle emporium. My goodness, some beautiful machines in there. If it weren't such a dangerous proposition, I would seriously using one as my major mode of transport at some time in the future. Maybe as fuel prices go up and up, the long-term future of personal transport is the motorcycle. If the majority of vehicles on the road were motorcycles, collisions wouldn't be so calamitous.
Visit the cafe's website for more information and some nice pictures.
Posted by GS at 5:04 PM
A small piece of Croydon (NSW) history
On Young St in Croydon, near PLC Sydney, sits a disused shopfront named The Bell Tower. As a shop it stands alone; it's surrounded entirely by houses. It's often made me wonder: what was this shop, sitting by itself, with that strange name? Who owns it now, and what purpose is it serving? (I always wonder that about derelict buildings...)
Anyway, it turns out that PLC Sydney have owned the building for some time and have been waiting to find the right use for it. It's currently being renovated and will serve as a lunchroom etc. for Maintenance staff, who have got by with fairly meagre digs so far. Before PLC owned it, it was a confectionery shop that served the needs of Croydon Public (primary) school directly across the road. That school has a historic bell tower on its premises, hence the name.
The shop is believed to have served some other purpose originally, and with a different name. The school is considering restoring the original name as part of its work on the building.
Posted by GS at 4:53 PM
Modern slavery
Not long ago, FIFA president Sepp Blatter described Manchester United's grip over Cristiano "Crybaby" Ronaldo as "modern slavery": he wants to go play for Real Madrid but United won't release him from his contract. It's a bit of a stretch – a contract is a contract – but it's a justifiable metaphor. It has occured to me in the past that the buying and selling of players by clubs and managers is a little analogous to slavery, although of course the players are well paid. (And what about the player auction that took place before the recent Indian Premier League cricket competition!)
Anyway, one or two black former football players got very cranky, very publicly, at Blatter's turn of phrase, saying how very dare he trivialise the pain felt by descendants of real slaves by using the term to describe these highly-paid celebrities. I guess he was asleep during the dozens of English lessons where they learned about metaphors. Or should I now be on the lookout for people daring to use phrases like "wage slave" or "a slave to process", and adjectives like "slavishly"? Idiot.
Posted by GS at 4:43 PM
Wednesday, June 4, 2008
Er, busy...
OK, so it's been a while. To say I've been busy would be rather an understatement. But that only excuses me for a few weeks, not a couple of months.
Anyway, enough genuflecting. I just posted a good piece on Midnight Rambler about Kevin Rudd losing some of his shine. It was going to appear here, but got too long.
Posted by GS at 7:08 AM
Saturday, March 8, 2008
Incredible new school concept in Washington
It is my limited understanding that there exists a middle ground between public and private schools in the US: charter schools that are publicly funded but self-run (i.e. independent of meddling bureaucrats). Or something. It doesn't really matter. All that matters is that a nascent Washington charter school called The Equity Project (TEP for short) is going to pay its teachers US$125,000 p.a. + bonus. That's rather incredible, probably double the average salary for teachers in the US (just my guess).
The school is guided by the principle that teacher quality is the most important contributing factor to student learning. They are setting high expectations of their teachers, of course. Not only will they have to demonstrate their expertise very thoroughly in order to get a job there, their job description goes well beyond classroom teaching to include professional development, extra-curricular activities and essentially running the school. To afford the teacher salaries, the idea is to employ only teachers as far as possible. Very few administrators, no substitute teachers, no professional development. Teachers take a forced sabbatical every five years, and spend six weeks of non-term time in collaborative curriculum and lesson development.
But it's not all hard work. It appears that teachers there would spend less time in the classroom than I do, and they teach only one subject at only one grade level. That is, a teacher may have four Year 10 maths classes, instead of, for instance, my current load of Years 7, 8, 9, 10 and 12. There's an obvious advantage to that: a smaller burden of preparation. The disadvantage is a lack of variety. I don't know which I'd prefer.
It seems that everything about this school is very interesting. The website certainly makes interesting reading. I hope to hear progress reports over the coming years.
A beautiful serendipity
Arvo Part (with an umlaut above the a) is one of my favourite composers. What's remarkable about this is that he's still alive. Most modern classical music is fairly inaccessible, but Part's music is very modern and usually hauntingly beautiful. (Some samples of his work can be found here.) Like some other modern composers, it is largely based on simplicity and purity, but this is done to profound rather than academic effect.
Anyway, I was just looking him up on Wikipedia to see if there were any new pieces of which I should be aware (answer: not really) and I happened on a link to a page which lists upcoming performances of his work worldwide. And wouldn't you know it, there's a performance of his Miserere in Adelaide tonight! Now for those who don't know, I'm a few hours' flight from Adelaide, so what good is that? Well, an optimistic visit to the ABC classic FM website was rewarded: they're broadcasting this concert at 11pm!
There are a couple of other pieces in the broadcast, seemingly by other modern composers. Should be an enjoyable and educational evening.
Wednesday, February 6, 2008
Principals to choose own staff
I wrote about this in Midnight Rambler yesterday. But Helen Pellegrino, in a letter to the Herald, has summed it up more succinctly than I could.
As a British teacher, I cannot imagine why teaching unions would oppose principals having the right to choose their staff (Letters, February 6). I understand that hard-to-staff areas might struggle to attract teachers, as do inner-city schools in England. However, a teacher whose main goal is to earn enough points to choose their next school is not focused on the best interests of pupils.
Of course, teachers are able to sidestep the policy by choosing to work in the Catholic or independent sectors. This means that public education misses out on some excellent teachers.Having worked with excellent principals and weaker ones, I insist on choosing a school whose ethos is aligned with my own. Likewise, a principal needs to choose staff who are committed to shared goals.
Friday, February 1, 2008
Thoughts for the day
It's been a crazy week: first week back at school. It's a flurry of information and activity as, for whatever reason, enrollments change and new students turn up to the wrong room, leaving me with a trail of administration as I wait until I see them. Anyway, amidst the chaos, some random observations...
- I'm surprised there's room in the market for two classical music stations in Sydney (and other capital cities). One is the nation-wide ABC Classic FM; the other is 2MBS, which runs in capital cities. I'm even more surprised that I generally prefer the commercial 2MBS over the ad-free ABC. The commercials are annoying, but ABC has its annoyances as well: in prime-time the style of music chops and changes, and the presenters talk too much. 2MBS flows nicely. This morning I got "stuck in the car" at work, simply unable to leave until the beautiful piece (Arvo Part's Spiegel Im Spiegel, which I have on CD) had finished. The perfect start to the busiest day of a busy week. However, right now I'm listening to the ABC station because I've just happened upon a program called Jazz Up Late, which is playing cool, interesting, modern jazz instead of the humdrum stuff you often hear on radio jazz programs.
- Desk clutter grows exponentially with time, even though the input is linear. That is, you add the same amount of crap each day, but the problem gets exponentially worse, not linearly. That's a problem, because we figure that a linear problem will have a linear solution, and get caught out. It's like introducing germs into a population at a constant rate: people will get sick at an exponential rate. The value of realising these things is that you are motivated to nip problems in the bud. (Disclaimer: I made all that up...)
- The Indian cricket thing has become a joke. I've resisted writing about it, but their repeated threat to send the players home if they don't get their damn way in court has actually made me not interested in watching their damn games. Almost equally amazing was the editorial from The Australian the other day (sorry, no link), which summarised the situation well enough, but said the Australian team needed to be supported in the national interest. I can hardly stop myself from swearing at this point. I try to maintain an open mind towards that august Murdoch plaything - sorry - august publication. It's nowhere near as one-eyed (towards conservative politics) as many people cheaply claim, and it some ways it's a model of balance. (Only in some ways...) But every now and then they publish such absolute bullshit that.... OK I'll stop now.
Wednesday, January 23, 2008
The Sham: all about Petersham
I live in Petersham, a cool inner-west suburb of Sydney. I was absolutely delighted, then, to discover the 'sham, a blog with rich observations of life in Petersham. It's the creation of Lucas Ihlein in his capacity as artist-in-residence during April and May 2006. From what I understand, his work was commissioned by Marrickville Council and after he had lived, written about and photographed his experiences, he created an exhibition which has been shown in Petersham (naturally) and in Adelaide.
Highlights I've discovered so far are his venture into the closed-down Majestic roller-rink, his long bike-ride with the mayor, and his description of the jelly-wrestling at The Oxford Tavern. His engagement with locals through the comments and various meetups organised therein is charming. It's awesome to read about so much local flavour on the Internet, and I sincerely thank Lucas for his effort and Marrickville Council for supporting it.
Tuesday, January 22, 2008
Book: The Teaching Gap
A friend and colleague lent me a book called The Teaching Gap. It looks at maths teaching in the US and compares it with maths teaching in Japan and Germany. The authors looked at heaps of video footage of maths lessons in all three countries to draw their conclusions.
It's very interesting to read. I'll just jot two points that have come up so far:
- The authors firmly believe that the difference between cultures is much greater than the difference within them. Of course, maths teachers within one country vary greatly in skill and style, but they all look fairly similar when compared with maths teachers from another country.
- An unnamed education expert, when asked to summarise the difference in style between the three countries, said: "In Japanese lessons, there is the mathematics on the one hand, and the students on the other. The students engage with the mathematics, and the teacher mediates the relationship between the two. In Germany, there is mathematics as well, but the teacher owns the mathematics and parcels it out to students as he sees fit, giving facts and explanations at just the right time. In US lessons, there are the students and there is the teacher. I have trouble seeing the mathematics; I just see interactions between students and teachers."
I'd love to observe some maths lessons in Hong Kong, Japan, China, Singapore, etc. Judging from the Asian students I teach, they cover advanced material significantly earlier than we do in Australia.
One more thing about gravity
Everyone knows that maths is important for science, but it's not always easy to present demonstrative examples of this to students. If a high school student studies physics or chemistry, the most advances mathematics they will need is probably solving or rearranging an equation, which is a Year 8 or 9 skill.
One of my favourite examples to talk about with students is calculus. It could be considered the crown jewel in the mathematical canon, but the fact is it was developed by Newton with an eye to his studies of planetary motion. It's a great example of a mathematical development being motivated by science. OK, that much I knew, but what about some details.
In the Feynmann book I referred to yesterday, it digs a little deeper. Kepler discovered three laws about planetary motion by observation. He looked at heaps of data that was collected on the location of planets at different times and noticed that:
- planets orbit the sun in an ellipse, not a circle
- planets sweep out equal areas in equal times, rather than equal distances
The beautiful thing is that from this one equation, Newton could mathematically prove that orbits are elliptical and that planets trace out equal areas in equal times. This is significant because no observation or experiment is involved (except in forming the original equation, which was a hypothesis). It was through mathematics, not science, that he could show that the known facts about planetary motion were a consequence of gravity.
Newton's work on planetary motion was great science and great mathematics. As a maths teacher, I want students to appreciate the importance of mathematics, even if they're not going to make a lot of use of it in their lives. Calculus is one of mankind's greatest intellectual achievements, and many high school and university students study in in detail. It's good for them to have some idea of how it has contributed to our understanding of the universe.
Monday, January 21, 2008
What makes the Moon orbit the Earth?
Years ago I bought Richard Feynmann's book Six Easy Pieces. It's only short, but contains fairly dense introductions to fundamental matters of physics. I'm enjoying the chapter on gravitation, because it goes into some detail on simple things I hadn't thought too deeply about.
For instance, we know the Moon is kept in orbit by the Earth's gravity, but sometimes I've casually wondered: if the moon is attracted to the Earth, why does it stay a constant distance away? Why isn't it visibly pulled towards the Earth?
Feynmann offers an enjoyable thought experiment concerning the firing of a bullet, which I'll try to relate. In it, we assume a steady Earth and no air resistance, so a bullet, once fired, maintains a steady path and doesn't slow down.
If you drop a bullet, it will fall 5m in one second (allowing 10ms-2 for gravity). If you fire a bullet at, say, 1000ms-1, then in one second it will travel 1000m horizontally but of course it will still fall 5m vertically. At some point it will hit the ground.
But the Earth is not flat, it is round. Without gravity, the path of a bullet would be flat. If you fired it horizontally, it would gradually get further from the ground and eventually fly off into space. The round Earth would curve away beneath it. With gravity, of course, the bullet "falls". So the straight path causes it to get further away from the Earth, but gravity causes it to get closer to the Earth. What if these two phenomena cancelled each other out? What if you fired the bullet so fast that in one second it gained 5m in height by virtue of its flat path, but also fell 5m in height because of gravity? In that case, after one second in the air, it would still be at the same height at which it started. During the next second, the same thing would happen: it would travel 1000m, but its lift would be cancelled by its fall. The bullet would, in effect, be in orbit.
That's how the Moon orbits the Earth. In a sense, the Moon wants to travel in a straight line at a high speed. That straight line would cause it to get further away from the Earth, but the Earth's gravity causes it to "fall" back into place. Thankfully, it's obviously going at just the right speed to stay in orbit. Too fast, and we wouldn't have tides. Too slow, and we'd all be dead.
Introducing Let it Bleed
Let it Bleed is a companion blog to Midnight Rambler. Whereas Rambler contains extended opinion pieces and is only updated a few times a year, Bleed will be short and sharp and updated rather more frequently. I don't think there will be any real consistency of topics. Maths, science, education, music, TV, news, whatever. I would expect posting frequency to be once a week, with a typical length one or two paragraphs.
Whence the name? Let it Bleed is the name of the excellent 1969 Rolling Stones album that contains the song Midnight Rambler.
Why the let-it-bleeed URL? Well, letitbleed and let-it-bleed are both occupied by abandoned blogs. (Check 'em out; they're both good for a chuckle and will take a few minutes to consume wholesale.) I just took what I could get.
Posted by GS at 3:23 PM