Code can be either DRY or WET. WET code stands for Write Every Time and is the opposite of DRY, which stands for Don't Repeat Yourself. The problem with WET code is that it is the perfect candidate for bugs. Let's say your test team or a customer finds a bug and reports it to you. You fix the bug and pass it on, only for it to come back and bite you as many times as that code is encountered within your computer program.
Now, we DRY our WET code by removing duplication. One way we can do this is by extracting the code and putting it into a method and then centralizing the method in such a way that it is accessible to all the areas of the computer program that need it.
Time for an example. Imagine that you have a collection of expense items that consist of Name and Amount properties. Now, consider having to get the decimal Amount for an expense item by Name.
Say you had to do this 100 times. For this, you could write the following...