One of the biggest reasons to refactor code is to eliminate duplication. It is pretty easy to introduce duplication in our code either unintentionally or because we don’t know how to prevent or get rid of it.
The three types of duplication
I’ve found that there are three basic types of duplication that we can eliminate from our code that successfully build on each other.
Most developers tend to get stuck at the data level, but in this post, I will show you how to recognize type and algorithm duplication and refactor it out of your code.
The most basic type of duplication is that of data. It is also very easily recognizable.
Take a look at these methods:
Pretty easy to see here what needs to be refactored.
Most developers don’t need any help to realize that you should probably refactor this code…
Ver la entrada original 484 palabras más