*

2006 / April 14th/ Beauty in less code

Tonight I added new features to Poetry with meaning (on my local machine) — but I actually reduced the total lines of code in the project. I’ve made myself a promise that every time I add something new to PWM, I’m going to make the code cleaner, meaner, and more beautiful. I cleaned up some nasty find calls that were duplicated throughout the app and shoved them back into the models, where they belong.

Programming is not always about hundreds of thousands of lines of code powering a monstrosity that can calculate a trip to the moon and back — it’s about loving your code. One of the things I love about Rails in the push in the community towards more beautiful code. It’s not just about adding features or optimizing connections — it’s about finding a poetry in the code. You’ll find developers taking a couple extra minutes just to clean up their code after it’s working and perfectly functional. It warms my heart to find changes like this one in the Rails core because it shows such passion in the core team.

Next time you’re working on your code, take some time and pretty up the place a bit. Rename a function, encapsulate something into a helper method - do that thing you put off until “later.” I promise you’ll find more passion in your work and end up with a better product at the end of the day.

A word from the sponsors. Advertise with Warpspire

8 Comments

comments feed

  1. Gravatar
    Tristan Dunn

    April 14th | #

    That’s the same reason why I love Rails. Now if I could only settle on one idea and complete it in Rails, that’d be great.

    By the way, your tag links don’t work.

  2. Gravatar
    Veracon

    April 15th | #

    I agree! Though I don’t use Rails (or Ruby for that sake), I always do my best to keep my code clean. That’s also why I’m writing a tiny Python framework that does what I need and nothing more (unlike Django or like). I’m hoping that a common page might just look something like this:

    def index(self, \*args):
        View('index').render(\*args)
    
  3. Gravatar
    Veracon

    April 15th | #

    Where did the indentation go? :O

  4. Gravatar
    Ryan

    April 15th | #

    Hear hear! Good words. It’s not always easy to want to go back and refactor code. If it works, don’t break it, right? But I think it’s especially important, as you add features, to think about how the new code interacts with the old code, and find ways to simplify existing stuff.

  5. Gravatar
    Kyle

    April 15th | #

    Veracon: I fixed it for ya :) Just some strange Markdown parsing stuff.

  6. Gravatar
    Veracon

    April 16th | #

    Thanks for fixing it, just one tiny mistake; it’s *args (asterisk), not _args. ;)

  7. Gravatar
    Colin D. Devroe

    April 16th | #

    I do this as well. My first pass on a project is very very rough, a “get to the idea” type of pass. Then I go back through to make sure it can take the load. Then I release it, then whenever I revisit the code I do exactly as you’ve said, I throw out the parts that are redundant, and do my best to make it as clean as possible.

  8. Gravatar
    Mike Stickel

    April 17th | #

    It has taken a long time for me to get to the point where I can optimize/clean my own code and I love it. After a certain point I think all developers ? at least the good ones ? do this. It is absolutely the best way to work IMO.

Make a Comment

don’t be afraid, it’s just text

Comments are parsed with Markdown. Basic HTML is also allowed.