This kind of question is usually uttered by people in regards to authorities such as the police, intelligence agencies, governments and the like. Because, according to them, authority is bad and can’t be trusted. The problem is, it’s not so much a rational question, but a demonstration of a paradox. Tree falling in the woods kind of thing, you know?
This post is about a couple of test driven development practices, let me present them to you with their rationale:
Workflow: Red Green Refactor
The point of this is you write a broken test–run the test, make sure it’s broken. so you know the test is broken, this is very useful when you type something like assert instead of assert_equal. Kent Beck relates a story of how him and a team spent hours trying to get a test to pass, when it was the test itself that was broken. the flip side of this is that you write a test that passes when it should fail. this leads to madness, believe me.
So after you’ve gone from Red to Green, you’re free to turn that ugly implementation into something pretty–and be sure you haven’t broken it during the process, all well and good. We love refactoring, now for the other practice:
You should refactor your tests, too
You should be treating your test code with as much love and due care as you do the actual implementation. Removing duplication and stuff. I must admit it took me a while to start thinking like this, but eventually you really do start to care that your tests are nice and easy to read. I mean, that whole communicating intent kind of thing. Test should do that, so yeah.
The paradox
Here it is. We write tests to allow us to refactor our implementation safely–who or what what is going to test our tests when we refactor those? Who will watch the watchers for sure (or who will test the tests in this case).
I bring this up because I don’t actually have a good answer. We have tools like Heckle which do a good job picking up your blind spots, but does that solve this problem in particular? Is there some other practice I’ve missed? Do we strive to write good tests straight up? Does it even matter?
It’s all so confusing and arbitrary. But that’s how we like it, yeah? Nah?! Aw.
Said
on September 03, 2007.
6 Comments.
Did I mention I was using migrations to post? Yeah, well turns out I end up editing and re-editing after I’ve deployed.
So, well, in typical Ryan style I’m going to rewrite this damn thing in Camping. And stick it behind nginx (oh by the way–it’s kicking arse on FlashDen).
Every time I go to update a post I have to write a new migration. Not on! I’ve got some other unorthodox ideas to try out. Screw this web form bull crap. Go svn commit and … something else.
Oh, and I have this fucking awesome surprise. It’s a big fucking surprise. I’ll tell all you all what it is soon. How ever many of you there are, which I doubt there are many (yet). Ha!
At last note: I would like to say how awesome Err the Blog are. They even now have their own company and everything! They are a testament to what a couple of passionate guys can do in a very, very big world. Of software. And shit. You know what I mean. Oh, and don’t forget about these guys either. They’re doing good stuff, too. That Warehouse thing in particular is very, very, very well done.
Said
on August 30, 2007.
0 Comments.
So, nginx, what is it? It’s what all the cool kids are using in their Rails deployment stacks.
I don’t quite run with all the new trends in rails (i.e. I’m not a huge fan of REST, I don’t run edge for any of my projects), but this is a story how we were backed into a corner, and really didn’t have a any other choice (except Apache, but lets not go there).
In fact, this is actually an (kind of) argument for nginx as the premiere load balancing proxy / web server for your deployment stack, but first some background…
We had been running Pound to Mongrels for, well, months. Months and months. Eventually we threw in Apache to serve out static content (and surprise surprise, it made a massive difference to performance), yet under load Apache would spawn ever more processes, consume ever more memory and in general just annoyed the living daylights out of me.
We took lighttpd under our wing and threw Apache out on it’s arse. lighttpd was great, he’d hang around, do his job, and generally not take up too much room or make too much mess.
At some point, I got right fucked off with Pound (I can’t recall why) and decided I wanted to promote lighttpd to the role of proxy balancer / mongrel herder. And to which we did, and lighttpd did a great job. And the configuration file was small, comprehensible and forthcoming–the kind of thing you could read to your kids as a bed time story.
But then something happened–we started doing more business. People were downloading more and more files, and at the time we had used the seemingly benign send_file. As in, buffer the whole file into memory (I think) then pass it to lighttpd. As in, for some reason not free up that memory. As in, OOM killer killing off lighttpd at midnight. As in, Pingdom sending me a series of SMS’ while I’m in Newtown with Dylan & Co. pissed as a fart. As in, not the best kind of situation.
So send_file was sending our Mongrels rabid and we needed a solution, fast. I recall one of my reasons for moving to lighttpd in the first place was to use this so-called X-Sendfile thing. Hey, I heard it was great, right?
Turns out you can’t use X-Sendfile with lighttpd’s mod_proxy, so unless you’re running fastcgi (but you’re not, are you? that’s a good developer) you cannot leverage it.
lighttpd 1.5 (not yet production ready) has a brand-spanker called modproxycore, a complete rewrite of mod_proxy, with X-Sendfile support.
I couldn’t get X-Sendfile with 1.5 working on my local environment, I just fucking couldn’t get it working, I couldn’t figure out if it was this alledged bug in Rails or some other reason or I’m just a complete idiot but I could not get the fucking thing working. I spent like 3 hours on it. I even fixed the alleged rails bug, didn’t even submit a patch (so sue me–last time submitted a bug fix it was never applied–boo hoo). It still didn’t work.
We were prepared to run flashden.net on an experimental lighttpd 1.5, but alas, it wasn’t meant to be.
After some oogling I had a feeling now was the time to look into this nginx thing. I remember hearing people say things like “it is great, it’s really fast, you should try it!” but I dismissed it as more REST-like hype. And you know how I feel about REST. Well, you don’t. I’ll tell you some time.
What turned me off nginx initially too was that it was not just a load balancer, and a web server, but it was also a imap/pop3 proxy or something, and I thought “shit mate, what fucking else are you?”. But when you’re left raw with nowhere else to turn you kind of start looking places you’ve never considered looking before…
Thus my love affair with nginx began. Of all the things nginx claims to be, it has some unique-ish features; like it’s X-Accel-Redirect header, kind of like the venerable X-Sendfile but unique to nginx. This is what we’re looking for, so I took nginx out for the day to see if we’d get along.
It turns out we did! By the end of the afternoon we had updated our application code and had a bona-fide configuration file courtesy of this bloke along with some of our own junk config. nginx had officially moved in.
The end result? No more memory leaks due to send_file. A seemingly snappier site and the ability to go out and get as drunk as I like not having to worry about the site going down.
lighttpd will always have a place in my heart, yet nginx most surely is the new black and I can highly recommend it in a production setting… At least until lighttpd 1.5 finishes its therapy…
Are you still there? If you hang around for a while longer I’ll go into specific detail of, well, things that will actually contribute to you and your work, i.e. how to implement this crap. Yeah that’d be good. I’m sure you’re into that.
Said
on August 26, 2007.
0 Comments.
This is not a tech post and it will add no value to you what so ever.
I’ve been in Sydney now for a few weeks, staying at a place called Balmain Lodge (it always looks way better in the photographs).
I’ve managed to ride it out on two pairs of jeans, a couple of t- shirts and a couple of jumpers but cleanliness is starting to hit critical mass.
For $280 per week you still need to collect $1 and 20c pieces to get your washing done. They lovingly provide you with detergent (but it’d hidden away in some nasty smelly cupboard), and dryers if you are partial to shrinking your clothes (which I’m not).
There are no lines to hang your clothes up on, though. So I’ve purchased a clothes horse, again. Every fucking time I’m in Sydney I end up buying another clothes horse.
To add insult to injury their dryers don’t dry. I’m sending my undies and socks on a second cycle in a perhaps vain attempt of not having to hang them out.
Additionally, I locked myself out of the room on Saturday morning–ironically on a trip to get change for the washing machine and dryer. I luckily had a wallet and my bank cards otherwise I’d have had to trek from Balmain to Bondi Junction to find Collis and/or Cyan. My phone was in my room, so I couldn’t call anyone. I had to use public phones. Half of them didn’t work.
A locksmith, a picked lock and $130 dollars later, I’m set back a good 24 hours washing wise. I had to go without undies today, the horror!
For $280 per week, there is no after hours number. I think at the very least there should be some emergency after hours number. I don’t care if I have to pay for the incident.
And guess what? The staff came a-knocking at 8:30am one morning to ‘make up my room’. I was in fucking bed! Hungover, damnnit! I now know what that security latch is for–it’s not for protecting yourself against burglars or thieves, it’s for keeping out the staff that want to change your sheets at 8:30am.
Life is just full of little dramas, isn’t it?
Said
on August 26, 2007.
0 Comments.
The other week, yet another example of sub-par hyperlink copywriting graced my web browser. As usual, I took it upon myself to point out that it was sub-par and that the W3C have an article on the subject.
But, the article has changed! The examples are poor! I have better examples. This threw me into another fit of rage. We need a stronger argument.
I say to Collis “I am so going to write about this when I finish my blog”. He replies “If I had a penny for every time you said you were going to finish your blog I’d be a millionare”. Touché.
I’ve taken it upon myself to shatter the possibility of him becoming a millionare by me not finishing my blog. He’ll have to become a millionare by other means.
So, expect a hilariously incisive rant on hyperlink copyrighting in the next week. If you don’t laugh at it I’ll laugh for you.
Here are some random facts about this blog:
There you go. First post up!
Said
on August 19, 2007.
3 Comments.