How do I help a coworker with more years of experience write cleaner code? Let's call them Dario. What are some tips on how to gradually introduce clean code concepts while still being respectful and helpful?
My teammate happens to write spaghetti code with unnecessary complexity. For example, instead of using the built-in forms API for Angular to keep track of the form state, they write these monstrosities that first loop over each item in the form, find the control they are looking for, and update the state.
Inside of these methods there are a lot of side effects and it's written in a very imperative way. As you can imagine, this leads to a lot of bugs that are preventable and as we add new features, it just takes longer to refactor and fix. A small example being a list of radio buttons that behaved like checkboxes (when you clicked on a selected radio button, the monstrous code treated it like a checkbox and set its state to be unchecked).