Friday, July 30, 2010

Repeat - Don't Repeat Yourself!

I am reading The Pragmatic Programmer: From Journeyman to Master by Andrew Hunt and David Thomas and I'm sharing my thoughts, questions, confusions and insights as I continue to read the book.

I have folders on my computer with same books, music, software, photos at more than one location. I routinely copy things (my idea of backup) and then would forget about it. Even my Linqpad queries (which I write to test and learn new code) are at more than one place (office, home, usb, Dropbox) and I can bet they are all different. When working on a active project I knew things start looking bad when I start repeating the same logic at more than one place. Now I have repeated myself a lot of times to make it clear that I do repeat things :)

I did attended object-oriented analysis and design classes in my uni days where you learned how to reuse code and good design principles. But, hey, no one told me to... well... not repeat myself! At least not in plain english. No one told me "DRY—Don't Repeat Yourself" when writing programs as that would have been a better advice.

At work the number one reason of repeating some things would be "Impatient Duplication" - time pressures - forcing us to take shortcuts. But, then again, I have spent many hours correcting something which could have been avoided by not repeating it. 

This is one of the first tips which seems to have influenced me. I did cleaned my PC today of duplicated folders. For stuff where I think I need history, I am making use of Subversion. Eliminating all duplication would be a hard task, but I am on it. Now repeat 10 times "DRY—Don't Repeat Yourself", as you know, repetition is the mother of learning!

No comments: