4 ms·
80% of the time the answer is "find out if the owners of the code are supportive of improving the code", and when the answer is "no", just put in your hours and
by Buttons840 4y ago
80% of the time the answer is "find out if the owners of the code are supportive of improving the code", and when the answer is "no", just put in your hours and collect a paycheck.
- leidenfrost 4y agoDunno, I successfully refactored some legacy services. Some of them even were a big index.js spaghetti files. You have to start with the smallest and most conservative to the most "refactory" ones: - figure out what enters and what exits from the program, and create a test suite that reflects every known combination - move parts of main() to funcions - figure out what variables can be converted from mutations to returned values - move thr ifs(){} to maps, early returns and such - figure out the database schemas from newly written data - infer model relationships fro further writes - attempt to implement some pattern design, even if its just dummy variables Sometimes you even have to do it at the last stretch of time of your workday, and slowly the mess will become clearer, your test suit more exhaustive and comprehensive. And at some point it will achieve feature parity with the legacy service
- mixedCase 4y agoThe GP is referring to the political costs of changing bad code, not the technical challenges which are almost always manageable by any experienced programmer. Egos, however.
- leidenfrost 4y agoYeah. But there were times where I did some hidden refactoring even if people said "no" if I asked for permission. In part to maintain sanity in a toxic environment, and in part because I knew they just accepted it if it was handed to them.
- eska 4y agoYou’re the guy in corollary 1 in this article. https://yosefk.com/blog/people-can-read-their-managers-mind.html https://yosefk.com/blog/people-can-read-their-managers-mind.... Either you’re successful AND your managers have an epiphany that you were right and they were wrong, or you fail and your managers will punish you for ignoring their instructions. It’s a risky strategy for an employee.
- cratermoon 4y agoUntil the friction of working in the terrible code becomes bad enough to slow down development to the point that the code owners complain about why it's taking so long to get work done. Of course they still won't support improving the code, but at least you have empirical evidence that never taking out the garbage turns makes the system look like a house in an episode of Hoarders