First of all, what does DRY stand for? It is a term “don’t repeat yourself”. In the software engineering world, this is a principle of reducing repetition in the code, referring to a single source-or “snippet” -of reusable code whenever you need it.
An example of this could be an app that your programed that throws a ball for your dog once an hour throughout the day. Instead of writing the entire code out for finding the ball, picking up the ball, and throwing the ball every hour, you can write the code once and give it a name such as toss.ball. This will then allow you to just type toss.ball each time to call it. This saves a lot of time writing the code.
Not only are we saving time when first writing out the code, but it also means that there will be less human error as well. From the example, if we were to write out the code entirely 24 times (1 for each hour), you would be bound to make some sort of error at least once. Another reason how this is also effective is that if you wanted to change the object being thrown for example a stick, all you would have to do is change the term ball once, instead of doing it 24 times.
In terms of real life, we can see this being used when we let websites save our information such as logins, password, or any other type of information we would have to type in each time. The same goes for music. If we are using sites such as Spotify, most of us create playlists so we don’t have to constantly look for the song we want to listen to.
I chose to write about this topic because it is part of our curriculum. We will be learning about this principle along with others as it is an important part of coding. I will post a link that will take you to a blog I read. https://zapier.com/blog/dont-repeat-yourself/ I really enjoyed going taking the time to go through this blog because it taught me and showed the importance of reducing time when it comes to coding. I also recommend this blog to anyone who plans to become a software engineer because it goes into depth about DRY and uses many examples to help you understand how it works. It amazes me how a simple principle could do so much such as saving time, less human errors, and overall having a simple code.
From the blog CS@Worcester – Michael's Developer Blog by michaelchaau and used with permission of the author. All other rights reserved by the author.