6 Tips for refactoring Code
(Just a short post give a quick read) Hey there, Refactoring is the process of restructuring existing code (changing the factoring) without changing its external behavior. So, I present you 6 tips for Refactoring code.
1. Remove duplication
Follow the D.R.Y principle and Don't Repeat Yourself. If you see code, functions. and/or logic being repeated, rewrite the code to remove the duplication
2. Improve responsibility
Ensure separation of concerns by having to separate things into sections that handle a certain 'concern'. Just avoid coupling of different logical entities.
3. Remove unneeded code and over-complexity
Remove anything unneeded to simplify the code and reduce confusion or "Why is this here?". Y.AG.N.I. (You aren't gonna need it).
4. Be consistent and follow standards
Sometimes it's better to stay consistent with the current project, even if there might be a better way. Follow standards where you can to make your code more predictable to others.
5. Adopt a design pattern when needed
A design pattern is a general, reusable solution to a commonly occurring problem in a software design. Always keep things simple first; only adopt a design pattern when the code begins to show it.
6. Pull-up / Push-down
Determine if methods, objects, and/or logic need to be consolidated at a 'higher' level, or need to be pushed down to a 'lower' one.
ðŸ“˜Thanks For Reading | Happy CodingðŸ˜Ž