DRY (Don’t Repeat Yourself) Principle in Java

DRY is simply an approach, or we can say, a different perspective to programmers. DRY stands for Don’t Repeat Yourself. In Java, it means don’t write the same code repeatedly. Suppose you are having the same code at many places in your program, then it means you are not following the DRY approach; You are repeating the same code at different places. Hence, the solution is obtained using the DRY concept by placing the methods in place of all repeated codes and defining the code in one method. So by calling methods, we will reach the principle DRY. The DRY concept is very important to make the code better by reducing code redundancy and to encourage its reusability. 

Leave a comment

Your email address will not be published. Required fields are marked *