Live data from Hacker News

The Economic Benefit of Refactoring

martinfowler.com

21–30 of 132 posts

Re: The Economic Benefit of Refactoring

#21
post #7

It's very interesting to have some data on this. It matches my experience which is that LLMs greatly benefit from well factored code, but are not particularly adept at creating such code. Much like most human developers I suppose!

I've been budgeting myself explicit "slop removal" time. In fact I'm in it right now one window to my right here.

I still get a big win from AI on the net, but you do need to budget some time to clean up. I'm still on team "read every line".

In fact this is a case where I deliberately deferred some review because I was a blocker for another team. Now that I've got something to them I'm going back and I'm going to eat a bigger chunk of debt than I normally would, but it's worth it for unblocking the other team sooner. AI has made tech debt easier to take out, in all senses of that term.

It is also pretty decent, in my experience, at being guided into how to fix tech debt. Some other people's experience varies: https://news.ycombinator.com/item?id=49035455 YMMV.

Re: The Economic Benefit of Refactoring

#22
post #7

It's very interesting to have some data on this. It matches my experience which is that LLMs greatly benefit from well factored code, but are not particularly adept at creating such code. Much like most human developers I suppose!

Out of the box, this is what I've found too.

I've had some luck while refactoring by helping it shape how to refactor, which can improve how well factored code should look like.

Providing examples of well factored code can go a long way, even if it's an open source repo of what to do / not to do.

Re: The Economic Benefit of Refactoring

#23
post #10

Interesting that the amount of code remained essentially unchanged. In my experience it is not unusual that refactoring messy code cuts the number of lines in half.

Quality of lines > Quantity of lines.

In some projects, the code might not have much, or enough testing, or documentation/commenting.

Code is largely for others and the future if the creators of it want to move onto other projects.

Re: The Economic Benefit of Refactoring

#24

Earlier quoted context omitted.

It can go both ways. Lines of code is a terrible metric for pretty much any goal that refactorings are meant to tackle.

I don’t know. LOC to me is indispensable for certain refactoring goals in my opinion. Taking a component and turning it from 7K lines to 3K lines and maintaining functionality obviously means there’s less complexity introduced, less to go wrong now, and less overhead to modify in the future. Sure it can go the other way, the component needs to support something it might need, we need to adjust larger patterns, this f…

LOC can be one measure, but not always the sole or best ones.

Since LLMs are word generators, and have a propensity to generating words, they need to be shaped to understand simplest is best, more isn't more, and less isn't more always.

Trimming down and cleaning up could be formatting, standardization, commenting, or even some basic re-architecting that was overdue.

One of the biggest benefits of llms for refactoring I'm finding is reducing technical debt.

Re: The Economic Benefit of Refactoring

#26
post #11

I have been enforcing this myself through AGENTS files and other explicit instructions. What’s crazy is that none of the existing coding harnesses include such instructions by default. Two lines in Claude Code and Codex and the entire world would be writing better, more efficient code. Makes me believe in the conspiracy that these companies want more verbose code and longer files because it directly results in higher…

Pray do share those two lines

Re: The Economic Benefit of Refactoring

#27
Can't agree more. Feels like LLMs are not able to understand your requirements at a high level and always add complexity by default. Really need a handbook to guide them to do those cleanups. Obviously they know the knowledge in their weights but they just don't know how to apply it.

Re: The Economic Benefit of Refactoring

#28
post #14

I think this is one of those things where a human in the loop is indispensable An agentic refactoring pass does make sense cause one LLM reviewing work can spot things the ‘generator’ LLM missed while focused on the initial task output But can the reviewer agent ever actually have in mind what this project actually is? And how the code all comes together to do the work involved? In other words what parts of the code…

Your take is outdated. Agents are excellent at refactoring now. If you told me what you wrote during an interview, that would be grounds to not continue.

It's very important that you are using coding agents with the latest frontier models and know exactly what it can't and can't do if you want to be hired in this market.

Re: The Economic Benefit of Refactoring

#29
post #14

I think this is one of those things where a human in the loop is indispensable An agentic refactoring pass does make sense cause one LLM reviewing work can spot things the ‘generator’ LLM missed while focused on the initial task output But can the reviewer agent ever actually have in mind what this project actually is? And how the code all comes together to do the work involved? In other words what parts of the code…

Your take is outdated. Agents are excellent at refactoring now. If you told me what you wrote during an interview, that would be grounds to not continue. It's very important that you are using coding agents with the latest frontier models and know exactly what it can't and can't do if you want to be hired in this market.

Interesting that you said the word ‘using’. Why is that? If an agent could refactor excellently without a human who is the user
Post reply on HN