Hacker News new | ask | show | jobs
by joncampbelldev 2032 days ago
This sounds very different to the process described in post. Are you raising this anecdote as an argument against the boy scout rule?

I don't think you would find many people who would consider his actions a reasonable interpretation of it. I think this person would cause damage regardless of their motto or underlying intent.

Taking a leaf from the guidelines for person-to-person,discussion on this forum about arguing against the strongest version of your opponents argument: I think there is great value to lots of small improvements over a long period of time (no silver bullet etc). Certainly it should be tempered with the knowledge that the change is indeed an improvement. That can usually only be decided by the person who originally wrote it OR a consesus of the team involved.

1 comments

The problem is that there is no objective measure of "better". The consultant did think he was leaving the code better than he found it.

I've worked on codebases where the whole team agrees a certain part of the codebase needs to be refactored, but we all also agree it is way too dangerous. Which is better? Working but hard to maintain spaghetti code, or clean, new, and broken code?

I think the all or nothing view may be the problem 'maintain spaghetti code' vs 'clean/new code'. When one inherits a code base like that one should start small. Write an automated test that tests a single scenario, add a comment that explains something particularly difficult that a developer spent a lot of time on finding out. Rename one single variable somewhere. Then gradually as one gains more knowledge start doing bigger refactors and bring more of the code under tests. It sounds like what has happened here is that a big bang rewrite was undertaken. This is almost always ill-advised.
I like to use the model that humans can only grasp so much, and that only increases slowly if at all, so on a mature project you have to try to keep the amount of stuff to remember constant. New code that adds new concepts needs to be counterbalanced by simplifying things elsewhere. As the inherent complexity increases, chip away at the accidental.

I sweeten the pot with management by pointing out that if you do this, it’s easier to ramp up new people. If you can ramp up new people, you can absorb new customers without making a fool of yourself in the process. We should want to be able to take on big new customers, right?

Thank you for explaining much more clearly and succinctly than me.
So for the consultant: Yes he did, clearly this consultant was an absolute disaster. An excellent cautionary tale of arrogance combined with lack of ability and design thinking. Changes made without thought / design or discussion with the team are unlikely to be "improvements", unless they're being made by someone intimately familar with the codebase (which an outside consultant cannot be).

For your second point, I don't really see the applicability of this specific concept of the boy scout rule to the situation of "business critical code that is in such a bad state the whole team agrees it should be rewritten".

However, were I to try to apply the concept to your situation, the first question to ask is "why are people afraid to change the code?". There's usually 2 reasons for this. Firstly, the code and the problem are super complex and hard to understand, this just takes a lot of time, to develop the knowledge and intuition around the code. Secondly, the code lacks tests (unit / intergration / functional / manual spreadsheet of test cases) that assert the behaviour you expect. Therefore my (unasked for and probably already known to you) suggestions for "leaving it cleaner than you found it" would be to make a start on understanding the code better through a series of very very very small refactorings. Pick one tiny function that is a mess and clean it up. At the same time, ensure your changes are correct by asserting all expected behaviour of that function.

If you are now saying "duh of course" well thats the point. I do not think a single reasonable person would suggest that a full rewrite of a complex business critical system that is either poorly understood, poorly tested or both is a charitable interpretation of what the article is talking about.

At the end of the day it is super easy to shoot down any idea or concept in programming, because we have so much power to abuse and ruin anything day to day if we're not careful. It's the easiest thing in the world to take a machete to a codebase without thought. But the problem there is the person holding the machete, they can't be trusted with it. I cannot think of a single thing that wouldn't be misinterpreted or done badly by some of the terrible coders I've met during my career.