How a Live Pet Project Can Help You Learn

Posted by on Feb 27, 2011 in Geekery | No Comments

I have a pet. It’s a bit of an odd pet, and it grew from a childhood obsession.

My pet is Unique Sentence, a website I run for saving, well, unique sentences. Sentences said in everyday conversation that you know have just never been said before. Like this one:

“Kylie Minogue is not going to come racing out of my belly button no matter how much you might like her to!” (permalink)

That was said by my friend Kavey to her husband Pete, and it’s safe to say that those words are highly unlikely to spontaneously crop up in that order again.

Okay, so it’s a strange obsession. But my point here is that I’ve got an interest that allows me to run a website as a pet project. It’s a website that I never plan on “monetising”, where nobody will die if it’s down for a day — or even a month — and it didn’t take a lot of code to pull it together.

It’s also such a minority interest that it’s pretty much guaranteed not to become popular, while being just interesting enough to a few friends that it does get some use.

I use it for practice.

It was the very first dynamic website I ever put live. I wrote it in terrible PHP, godawful HTML, misunderstood and hacked-about CSS, with a sprinkling of Javascript, mostly copied out of a book about Ajax I got from the library. Really.

Of course, I thought it was brilliant. Because when you spend so long programming something new and it eventually works, that is brilliant, no matter the underlying quality of the code. You’ve climbed a steep learning curve, and you’re happy with the view from the top, no matter how you got there.

And that’s why I have a pet project. Because while I’m learning, I can make all those mistakes on a project that’s not so important. A project I can burn to the ground and restart from scratch with a different approach, just so I get to understand that different approach.

Because it’s a live project, it helps me see real-world problems in web design and programming that I wouldn’t see through doing simple tutorials.

For example, I recently did burn Unique Sentence to the ground and rewrote it from scratch. I’d learned a lot more about web programming, and it was time to have another go. In particular, I wanted to try Symfony, a big shiny MVC framework.

Symfony has some really good documentation. In particular, it has the Jobeet tutorial, a project that has you build a working job advert site from start to finish.

The Jobeet tutorial is excellent1. But no matter how good a tutorial, tutorials do their best to keep you away from pitfalls, and there are always knocks and bumps that the real world will present that a tutorial never will.

So, after finishing Jobeet, I rolled up my sleeves and got started on Unique Sentence.

And that’s where the second level of learning starts, really. Unique Sentence is my real-world tutorial. It has a defined end-point — it should work pretty much the same as its existing implementation — and it’s simple enough that I knew I should be able to get through it with the basic knowledge of Symfony I had.

But from start to finish, I bumped into things unmentioned by the tutorial and the gentle introduction, weird issues specific to what I was doing, odd things I had to do because of my existing codebase, issues with deploying onto my VPS setup, and so on. Because you do. That’s what the real world is about.

Among other things, I found out that you need at least three different Symfony plugins to get a half-decent user registration system off the ground, and that their code is fiddly to get working and customise. The real world, of course, is full of spamming bastard botnets, so you need email-validated registration and CAPTCHA systems in place, which is generally out of the scope of framework tutorials.

I figured out how to plug PHP Typography into Symfony so I could render my sentences with smart quotes and nice hyphenation. And learned a lot about Symfony’s automatic output escaping, mostly because it kept on getting in my way.

I learned how to migrate data — all those existing sentences and users — from an old, non-Symfony system to a new one.

I found out that while Symfony’s functional test system is lovely, and even has a built-in “mailer” tester for checking the bodies of emails you send, it doesn’t work if you’re sending multipart mails, i.e. combined text/plain and text/html. That was when I learned how to extend a Symfony tester class to add my own custom type of test.

I learned that some Symfony plugins2 hardcode their forms to the opposite style of the Symfony default (lists rather than tables), and weld their CSS into your site quite hard. Grr.

Because I was a young and foolish and trusting idiot when I first wrote Unique Sentence, all the passwords, though properly hashed, weren’t salted. So I learned how to extend Symfony’s user management plugin to migrate users to Symfony’s standard hashed-and-salted passwords as each existing user logged in. After all, I didn’t want to “do a Gawker“…

I learned where to ask questions about Symfony — both Stack Overflow and the Symfony Users mailing list are good. The user forums, however, seem to have tumbleweeds blowing across them, though they’re a useful source of archived information. I learned that virtually every web search you do for a specific Symfony function drops you at the out-of-date documentation for a three-year old version of the function, even when the latest docs are available. Sigh.

And I learned a whole truckload of other stuff, which is my point.

I knew when I’d finished, because Unique Sentence worked like it had before3. This is important: have a small project with a definite end-state, or you can procrastinate forever without it hitting the real world.

I didn’t risk any real-world deadlines, I didn’t take the chance of breaking any important sites. I made a lot of mistakes while I was doing it, and there are definitely things that I would do differently with Symfony now I understand it more. But my learning didn’t hurt anyone. Other than the occasional bashing of my head into the desk when I figured out what dopey thing I’d just done wrong. And now there’s a new, shiny version of a site that only about five people actually care about, which is not necessarily a bad thing.

And that’s why I’ve got a pet project, odd beast though it surely is.

When you’re learning a new framework or technology, do you find yourself with a learning “gap” after you’ve finished a tutorial? Do you sit there, having absorbed a whole lot of information, but unsure whether you could actually write anything from scratch?

If so, I really recommend a pet project. Pick one that’s just complicated enough to be useful, and where it might get some real-world use. A simple idea, a personal obsession, anything like that. See if you can come up with something that some tiny niche of people — weirdos like you, in other words — would find interesting, and actually use to some small degree.

It’s a great stepping stone between a tutorial and the harsh real world.

 


  1. although if you’re thinking of making a tutorial for programmers, I’d personally advise against choosing one that will make everybody in the company who walks past your desk think you’re looking for a new job rather than working []
  2. I’m looking at you, sfForkedDoctrineApplyPlugin! []
  3. Though it’s a bit prettier, and underneath, the code is about a hundred times cleaner. It’s all shiny and nice with templates and slots and partials in the view, a Lucene-based search, and a backend database generated entirely from a Doctrine config file []
« A SQL Server Correlated Subquery Gotcha | Review: Withings Body Scale »