Ask HN: How have you dealt with a team that is afraid of refactoring?
7 points| ThorinJacobs | 8 years ago | reply
As I am fairly new on the team, my approach has been to add more and better unit tests, and slowly improve the code via small refactors, and let the results show themselves. This seems like a very long game to play, however, and I'm not sure if it will succeed.
[+] [-] psyc|8 years ago|reply
[+] [-] potta_coffee|8 years ago|reply
[+] [-] relaunched|8 years ago|reply
The assumption that refactor leads to breakage doesn't have to be true. It might be, if you are coding in a live environment, if you aren't feature / issue branching, if you aren't breaking up coding work into modular pieces, or any other number of scenarios. If that's the case, the benefits of a modern workflow should be discussed and a new process introduced. Baby steps.
Thorough tests may be a side of a high quality code base. But, the value of them is about reducing bugs / errors. Start with that and lead by example. Once again, have a discussion about the value of adding something.
Same with code quality...however you define it.
Now, since you are new, it seems like you've worked other places that were engineering enlightened and you want to show everyone a better way. Be careful so that your enthusiasm / experience doesn't come across as you being an know-it-all, condescending, superior, etc. First, lead by example. Second, share, preferably when asked. Lastly, teach.
If you weren't hired to modernize practices, and even if you were, you have to become a part of the team first, before you can change it. People have to know you're invested in them before they'll invest in you. Which is so say, no one cares about what you have to say, until they know that you care.
Good luck!
[+] [-] UK-Al05|8 years ago|reply
Code quality is often the result of how much the business values good code. If they don't they will simply want everything done the fasted with no time for refactoring.
That sort of pressure comes from top and is hard for a single dev to change.
[+] [-] ThorinJacobs|8 years ago|reply
This sounds like very sound advice - slow and steady wins the race I suppose
[+] [-] codegeek|8 years ago|reply
This is the key point. Yes refactoring is not a bad idea but have you spent enough time with the current codebase to understand why things are done the way they are ? Even if the code is sphagetti, the point is that you may not have all the background yet on things and you need to spend a bit more time understanding everything before you suggest major refactoring. Not to mention that unless it helps with real dollars (more money for the team/company), you may face resistance.
Having said that, don't be afraid to challenge status quo but make sure you have enough background information before making assumptions. It is much easier to come from outside and look at everything being broken (which may very well be but still need to understand it in detail).
[+] [-] ThorinJacobs|8 years ago|reply
So far I've been trying to keep my changes in service of a specific feature, and keep as light-touch on existing code as possible whole still making improvements. Wrapper classes have helped with this a lot.
[+] [-] UK-Al05|8 years ago|reply
Good code should be easy to pickup even for newcomers.
Now there maybe reasons why it's bad, time constraints, no time for re-evaluating the design. But that doesnt change the fact that it's bad.
[+] [-] pcmaffey|8 years ago|reply
2. Write functions, components, patterns (etc) that make other people's lives easier.
3. Earn trust over time in small ways like this, and you will be entrusted with bigger architectural refactoring decisions.
The only reason a refactor will ever get approved is if it can demonstrably lead to increased efficiencies in the near future. This is often true (when done well), but you have to be able to demonstrate why, beforehand - which is the hard part.
[+] [-] bryan11|8 years ago|reply
Performance testing can highlight areas of the code that need help, so work to improve scaling and performance abilities can be used to justify resources to refactor related code.
Sometimes a new feature request can be used similarly where the refactoring and new feature development is a better option than trying to develop only with existing code.
[+] [-] tonyedgecombe|8 years ago|reply
This is the key point, you almost certainly weren't hired to "fix" other members of the team.
This seems like a very long game to play, however, and I'm not sure if it will succeed.
To some extent it shouldn't matter, if you have a long career in this business you will inevitably come across broken teams and dysfunctional organisations. Knowing you are doing good work keeps you sane in these situations.