1. Dec 13th, 2007

    Rounded Corners - 173 (Beautiful code)

    Chained together. Cool Ruby trick, courtesy of Nick Kallen.

    Naturally, sorted. Natural sort algorithm adapted from Thomas Hurst’s adaptation of Ned Batchelder’s Python code:

    module Enumerable
      def sensible_sort
        sort_by { |key| key.split(/(\d+)/).map { |v| v =~ /\d/ ? v.to_i : v } }
      end
    end

    There’s also an internationalized version. Anyone wants to take a stab at a Ruby implementation?

    Overflow. Sometimes abstractions are better:

    I’d expect any competent programmer to be able to read (low + high) >>> 1 and be able to see what it is meant to do. I’d expect a good (and experienced) developer to use calculateMidpoint( low, high ) because it is a little easier to read, but more importantly, much less likely to have subtle bugs in it.

    As much as I worry about diminishing skills, (low + high) >>> 1 is a good example for what not to know. It’s a recipe for a classic overflow bug, not beautiful in any way, and one thing I unlearned when I stopped low-level coding in C.

    To be or not to be? The rest of the thread is interesting:

    All that just screams that many people in IT today do quite obviously not have the necessary basic training. They might learn how to plug Hibernate into an enterprisey Java application and how to battle XML config files, but there does not seem to be a computing 101 course any more. It’s as if a garage mechanic could only read the diagnostic codes from the motor microprocessor but has no idea that there is oil in the engine (or why, for that matter).

    There’s a whole class of developers who are able to plug components together but have no understanding of the underlying mechanisms. So you get things like 1+N queries or iterating over and updating individual records, just to name a couple. That’s bad.

    But these factory workers that are only able to follow directions and assemble prefabbed components into working products without understanding the product itself or the underlying mechanics … is that no the holy grail of the software industry?

    Readable is beautiful. After all, it’s all about working at the right level of abstraction. Andrew Binstock recommends Implementation Patterns.

    Picture, Savage Chicken, and felt relevant to this post, but I can’t explain why. So there, enjoy.

    Flexible Rails
    • Flex 3 and Ruby on Rails 2 integrated with HTTPService and XML
    • RESTful Rails controllers that support Flex and HTML clients
    • Coverage of how to use Cairngorm to architect larger Flex applications
    • A full application--not just a toy--developed and refactored iteratively
    1. Dec 13th, 2007

      Sterling Camden

      Maybe it’s just that I’m more familiar with Ruby, but your version sure reads a lot easier to me.

    Leave a Reply | Trackback | Track with co.mments

    Where's my comment? I get too much comment spam, so I have to moderate comments. Damn those spammers. If you don't see your comment immediately, be patient. I'll approve it the minute I see it. Want to know when your comment shows up, or check if anyone responded? Track it.

    Or using OpenID