While trying to learn coding in Java and it’s principles, I came across a problem with the DRY principle. From what I know, following a principle is not mandatory but if you should for many reasons.
While coding a program, I ended up with a bunch of methods and a button and a JtextField. When you press the button it gets app, takes the text from the jTextField and process it through the methods and shows the result.
Let’s say that I want to create another button that does all the above except the part were the app gets the text from the text field. For example it will get the data from a database.
Should I just copy-paste all the code from the first ActionEvent to the new button or would that violate the DRY Principle? How should I approach this dilemma?