Refactor Therapy #FrontendCode
Apr 21, 2021 · 1 min read
Refactoring is the process of (🤞) improving a piece of code. Usually we do refactors when we have repeating code that can abstracted, when the code is too confusing, when the requirements changed and the assumptions made before no longer make sense.
Refactor does not always mean to reduce the amount of code, sometimes it means making things more explicit, adding comments, renaming variables, extracting magic numbers.
Refactors are a great way to onboard someone into a project, as it requires you to really understand what the code is doing and ask questions in order to be able to improve it.
Refactors are also an interesting learning opportunity, as you can spend some time researching what other ways exist to solve a problem, you can ask for help to your peers, or you can help your peers with suggestions and feedback.
Refactoring can also be a development process: first you write whatever code you can think of to produce the desired effect, when you verify it’s working then you can refactor it to make it more efficient, cleaner and easier to understand.