Thursday, July 27, 2006

OSCON: Day two part 3

I wanted to get back to the hotel to pick up my phone but didn't get a chance. After Guido's talk I met up with Adam and David for lunch. Joining us was Mark Jason Dominus, a well-knowm Perl trainer. We walked to an Ethiopian restaurant and discussed all sorts of interesting technical stuff on the way there and back.

After lunch Adam I ducked into Damian Conway and Larry Wall's Perl6 language talk. We were a few minutes late, but what we saw was frankly a bit scary. We already knew that the main benefits of Perl6 over Perl5 was syntactic sugar, but this is insane. It's certainly expressive, but there were a couple of things that had no apparent application other than writing obfuscated code.

After that was Mark's talk about programming red flags. This was great stuff. It turns out Mark and I are both fans of the Daily WTF, and his first example of a "red flag" was truly heinous, definitely a WTF. However there was an important point hidden here, which is that even code that seems overly complex sometimes has relevant side-effects that a later maintainer must keep in mind. Before "fixing" broken code, you'd better be sure that you understand the context in which it's used. This has certainly come up during our refactoring of the Shopzilla codebase.

Another important point was that many experts are fond of saying "always do this" and "never do that." The point of red flags is not that they're always a bad idea, they just indicate that there is probably something wrong.

One easy-to-spot red flag is repeated code. He provided a large number of examples to underscore the point the when we see what we think are repeating patterns we begin to miss the details. Another one was a large if block without an else. Again, this isn't necessarily a bad thing, but it should cause one to rethink the approach. The bulk of the presentation dealt with an example program that he stepped through, fixing the red flags. The corrected version of the program code was 38% smaller and ran faster as well.

This was an excellent talk. I can see why Mark has been so successful as a trainer. He's articulate, humble and not at all dogmatic. What a pleasure to watch him work.

0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Home