Refactoring code into fewer lines does not necessarily reduce its complexity

May 20, 2009

Developers are almost universally aware that they should try and write code that is simple to read and maintain.  Complicated code can be a stumbling block for another developer (or even yourself at a later date) when he/she needs to fix bugs or modify functionality.

So refactoring existing code in an effort to reduce its complexity is definitely a good thing.

But refactoring code into fewer lines does not necessarily mean that its complexity has been reduced.  In fact, the opposite can occur.

Take this example posted by an Intel blogger.  While I fully agree that lambdas are awesome, and I eagerly await them in C++0x, I don’t agree with his assertion that the lambda version of his example is simpler.  Regarding his first non-lamda version, he concludes, “The code is indeed complex. It contains too many lines and three methods.”

Certainly the first example has more lines than the lambda equivalent.  But on its own I wouldn’t call the first example complex at all.  It has a function event handler for the control, a function for the thread, and a function for the UI callback.

The lambda version just puts the thread function and callback function into anonymous functions inside the control’s event handler.

Syntax-wise, I’d argue the lambda version is more complex than the first.


The Last Days of Copyright

May 19, 2009

Via Slashdot:  Sony Pictures Entertainment CEO Michael Lynton was recently quoted as saying, “I’m a guy who doesn’t see anything good having come from the Internet.  Period.”

This quote was from a discussion about the future of filmmaking and obviously the internet, piracy and copyright.

I can understand Mr Lynton’s pain, being the CEO of a movie company that loses money due to piracy.  But for better or worse (depending on your point of view), things have changed.  In fact, I posit that there’s no going back.

Users have had a taste of the good life, and it’s sweet.  They won’t accept an 88 mph Delorean-inspired drive Back to the Past.

Sure, BitTorrent traffic could be disabled.  Communities and web sites can be sued and taken offline.  But the posse will just move on to a new system, like they’ve done previously.

Instead of complaining, Sony et al should be coming up with solutions to embrace the new media distribution world that consumers have moved into.

Here’s a distribution model which I came up with a few years ago and will happily publish for free:

Bob visits the Fox web site and can browse every TV show & movie that Fox has ever produced.  Bob pays $1 to download a high-quality episode of the Simpsons with no adverts and no DRM, and can copy and watch it on whatever devices (TV, computer, iPod) that Bob likes.

Alternatively, Bob can watch the whole episode for free (via a stream), but with local adverts included.  Similar for movies.

Admittedly, songs are a bit tricker, but iTunes does well with its current system.  It’s mainly TV and movies that need to play catchup.

Will Bob pay the $1 and then share the high-quality episode on BitTorrent?  Maybe.  But piracy won’t be anywhere as prevalent as it is right now.  The majority of users will happily visit Fox and legally watch the episode for free (with ads).

Why?  Because consumers simply want to watch their favourite shows/movies.  Their goal isn’t piracy; it’s to watch their shows.  They hate waiting to see their favourite shows, especially when they know it’s already aired somewhere.  They don’t want to wait 6-12 months for a U.S. show to appear on their local TV stations.

And they don’t want to miss an episode because they forgot to set the VCR/DVD/HDD recorder.

With this model, the consumer definitely wins.  The creator/content owner wins too, since they’ll get revenue either by ads or by direct payment.  Who loses with this new model?  The middle-man TV networks.  If consumers can buy (via ads or directly) their shows from the creators, then Bob doesn’t need BBC1 or Channel 7 or whoever.  Likewise with cinemas.

But that just presents a new challenge and opportunity for the TV networks and cinemas.  They’ll certainly have to work hard to entice consumers to watch their TV networks or visit theirs cinema rather than going direct to the content creator web sites.  But so what?  Competition is good.  Cinemas didn’t die after video/DVD stores came out.

People will pay for quality, which is why even today with massive screens and surround sound systems, people still enjoy (some) cinemas.

So to Sony et al, I say:  Come on!  We’re here waiting, ready to pay (or watch ads) whenever you’re ready.


Casillero del Diablo 2007 Cabernet Sauvignon

May 18, 2009

I’m delighted to report that the Hendo Wine Rating (HWR) has gone global!  To date only Aussie wines have had the honour of a HWR, not because of any xenovinophobia (TM) on my part, but simply due to the abundance of great wine in Australia.

With my relocation, however, I now have countless European wines on my doorstep.

But I’m going to skip Europe and head first to South America.

Casillero del Diablo is a cab sav from Chile which we enjoyed recently with friends.  It originates from the Central Valley appelation and apparently contains hints of mocha and dark chocolate, though I’m not sure how to distinguish between them.

By now, though, I can distinguish between rubbish and good wine, and fortunately this falls into the latter category.

HWR:  4/5