No one enjoys having to say something over and over again. Repeating yourself can definitely be exhausting and even take you out of the mood of what you were doing, if severe enough. The same can definitely be said for coding. Having working code is always awesome. Having working code that isn't very wordy...even better.
Chances are you've probably heard the acronym DRY when referring to code. It's gonna be something that follows you down the path of being a life long student. DRY(Don't Repeat Yourself) is a principle of computer programming that promotes the reduction of repeating information. It makes sense though, consider basic variable assignment:
let a=1;
let b=2;
let c=3;
These three lines of code can be reduced to one, avoiding having to use the 'let' key word over and over.
let a=1, b=2, c=3;
This reads the same as the wordier example above. This could definitely be helpful in cutting down on typos that could lead to bugs that you would have to seek out. While you probably won't start out writing DRY code all the time, its still something you should practice when you get the time to. Having working code, once again, is always great and will mold you in to a good developer. DRYing up working code and having it still work as intended could aid in making you a great developer. Happy Coding!
Top comments (0)