Friday, November 2, 2012

Should you reinvent the wheel?

One important concept we've all heard a billion times is Don't Repeat Yourself.  Simply put, this means that we shouldn't copy/paste code all over our code.  That's what functions were created for in the first place.  There's another side to this.  Obviously, re-using the same code again and again is a recipe for disaster (you need to change something in 40 places?  Too bad).

There's another angle we can look at this.  If there's already an email framework or database abstraction out there, why write your own?  My absolute favorite part of the open source movement is that we now have access to thousands of libraries, frameworks and plugins not only for free but we can view the source code as well.

The reason viewing the source code is so important is that we can learn from a product instead of just using it.  Anytime I want, I can load up GitHub and learn how to find Waldolearn (and help develop!) an entirely new language, or crank out some poetry.

Full disclosure: The Haiku one's mine.  And I made it despite the fact that many other generators exist.  Am I "reinventing the wheel"?  Absolutely.  Did I learn a lot about Python and the English language while I did?  Also absolutely.

Reinventing the wheel isn't a bad thing.  It may be tedious in some scenarios, but it's a valuable tool in your utility belt.  It's a key step along the way to increasing your knowledge.

Richard Feynman said it best: "What I cannot create, I do not understand."

No comments:

Post a Comment