Ask HN: How do you deal with a sr dev writing bad code?
My boss has written several libraries that are all badly architected due to lack of understanding of the language itself and assigned me to manage and extend them.
The glaring issues in these files are more than I can take, they add more hours of work than rewriting the libraries correctly.
My dilemma is that if I rewrite them, I'm essentially calling out the sr dev. I can't see a way to frame the situation as something positive for both of us.
7 comments
[ 4.1 ms ] story [ 37.9 ms ] threadExample, "Enumerate FooKinds at a single point" instead of "Removed code duplication".
This is a social problem, so the solution must be social as well. Careful communication is the key.
Communication also means to listen. In this case, listen to your boss. Sometimes there are good reasons for "bad" code. Can you proof that your refactoring is an improvement? In most cases no, because many things are subjective. You might decouple components, which is good from a software engineering perspective, but insert a redirection mechanism, which makes it less simple.
The code is similar to something you would expect to see from a brand new developer, common mistakes made due to a fundamental misunderstanding of the core language functionality.
When things go side-track (i.e. really bad) talk to his supervisor.
On the other hand some people act is if their code comes straight from God on High and flows into this world through their fingers and may not be touched by mere mortals like the rest of us. In that case you might as well give up now.
The fact he's assigned you to manage and extend them suggests he might be nearer to the first approach, in which case just have a talk with him. You'll hopefully find that he'll be open to having you improve/rewrite them while he learns his mistakes.