

Ask HN: How do you deal with a sr dev writing bad code? - jrdev

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.<p>The glaring issues in these files are more than I can take, they add more hours of work than rewriting the libraries correctly.<p>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.
======
tompko
It depends entirely on the senior dev. If it were me I'd be glad for the
pointers from someone more experience with the language than me. Even the most
junior of devs probably knows more about some particular subject than I do,
and I'm always willing to learn.

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.

------
qznc
Rewrite and strongly focus on the improved parts. Never say or suggest that
the old code was "bad". Besidse, are they really bad? It is working code,
isn't it?

Example, "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.

~~~
jrdev
In this particular case, the changes are all trivial improvements, there is no
complexity introduced, just needless complexity removed, with better code
construction, as the previous code is actually impossible to extend.

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.

------
ktarnowski
Can't you just talk to him directly? Present your arguments in an honest and
respectful way, then see what his reaction will be. There's a good chance that
you will be able to resolve the situation without much of a fuss. He might
even appreciate the feedback.

When things go side-track (i.e. really bad) talk to his supervisor.

~~~
jrdev
He doesn't have a supervisor.

------
korynunn
I quit. Best decision I've ever made for my career.

------
pizzatown
Who's hiring?

