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.
8 Comments
Make a Comment
don’t be afraid, it’s just text

Warpspire is the place that web professional Kyle Neath writes about the web. 



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.
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:
April 15th | #
Where did the indentation go? :O
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.
April 15th | #
Veracon: I fixed it for ya :) Just some strange Markdown parsing stuff.
April 16th | #
Thanks for fixing it, just one tiny mistake; it’s *args (asterisk), not _args. ;)
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.
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.