Symphonious

Living in a state of accord.

Should You Publish Crap Code?

EarI spent the weekend discovering just how poorly thought out and poorly supported closed captioning is in online video. Some highlights (based on the SRT format because that was the only one I could find any information about syntax for):

  • Definitive guides to the format either don’t exist or are so poorly used that they don’t appear in the first 3-4 pages of a Google search.
  • Timestamps use a non-standard format. The inventor was apparently French so instead of the usual hh:mm:ss.ttt the period is replaced with a comma. I sympathise with everything being US-centric, but the number of people who were making this mistake on forums etc and the number of players who support period but not comma (and visa-versa) is scary.
  • Only DOS line endings are supported. \r\n is fine as part of the standard, but why can’t players be a little liberal in what they accept? It’s not like \n or \r by itself within the caption is going to work anyway…
  • No standard font, so no way to know if the caption will fit or not.
  • Absolutely zero feedback from any player I found about why it was ignoring the captions.
  • Really, really poor tooling support for creating captions.

So, coming around to the real point of this post, I wound up writing my own tool to help take a script, synchronize it to the spoken voice and output the right format. Worked a treat, and now I have working captions on my video. I suspect it would be useful to others and there’s certainly plenty to do to improve it that would be great if others jumped in and helped with.

The trouble is, to make playing the video easier, I used Cocoa and Objective-C. Great decision, got me up and running in no time – with really, really, really, lousy code. See, I haven’t done anything more than vaguely dabble in Objective-C and I’ve only used XCode back when it was Project Builder and I suspect OS X was in beta. Needless to say, the resulting code is terrible. I didn’t want to learn all the ins and outs of the Cocoa document system and where I’d have to change the names of things so the main document class is still called “MyDocument”. I think I turned on the Objective-C garbage collection, but if not it will leak like a sieve (it might anyway, not sure).

If you look at it one way, it’s pretty impressive to pick up a completely new tool set and get a useful application out in a morning, but more likely you’d look at the code and decide I was incompetent. So the great dilemma, should I push this rubbish code up to GitHub and hope someone comes along to refactor it, or will it just sit there waiting to appear in a Google search when I next wind up applying for a job, thus killing all my hopes and dreams?

  • Rob Dawson says:

    > or will it just sit there waiting to appear in a Google search when I next wind up applying for a job, thus killing all my hopes and dreams?

    You say that as though you will leave your current job. You know that you will never leave :).

    April 27, 2009 at 9:27 pm
  • ddoctor says:

    This is a hypothetical, right? I didn’t think you knew how to write crap code. :)

    April 27, 2009 at 11:36 pm
  • Adrian Sutton says:

    Ok, it will probably just come back to bite me when I next jump up and down at engineering complaining about the way something was implemented. Though usually the result of me doing that is someone just pointing out that I wrote the damn code in the first place anyway so perhaps this is an improvement.

    As for hypothetical crap code – no, no. I am master of all code – I can write the best code you’ve ever seen and (especially when I try to use Objective-C) the worst code you’ve ever seen. Drunken coding results in either one of those extremes but you can never tell which until the next morning. :)

    April 28, 2009 at 1:35 pm
  • Pete Royle says:

    Invent a double-life and complete back story, and post your code to GitHub as Prof Patrick Starfish. And I’m with you on the drunken coding :).

    May 2, 2009 at 8:18 am

Your email address will not be published. Required fields are marked *

*