torstai 5. tammikuuta 2012

Don't Repeat Yourself

In movies, have you ever heard of saying "Don't make me repeat myself!"? We all hate saying the same thing to someone again and again, but why is it that we tend to use the same block of code multiple times across our applications?

Today was an interesting day for me, as I got to observe bunch of talented developers speaking about how things are done and what should be concidered while doing it. One thing they discussed was DRY development method, in others words, Don't Repeat Yourself.

In other words, what they were talking about was the usage of copy/paste to generate whatever you are trying to generate. In order to develop maintainable code, one should never copy function from another place to have a certain outcome. The code should be written in such a way, that the information, or a process, is obtained from one single place and used where ever needed. If you need to somehow refactor this certain process, it is an easy task due to the fact that logic behind it needs to be refactored only in one place.

I have seen, and yes, used myself the bad habit of copying something from another place in order to get something accomplished fast. Later on, I noticed it wasn't the smartest way of approaching the problem, thus generating more refactoring to be done whenever time allows.

I knew how this problem exists but I never knew it has a term... until today.

Ei kommentteja:

Lähetä kommentti