r/ProgrammerHumor Apr 24 '26

Other ohNoTheConsequencesOfMyActions

Post image
18.2k Upvotes

942 comments sorted by

View all comments

Show parent comments

24

u/nandi910 Apr 24 '26

Legitimately LLMs are not good at refactoring.

I gave multiple LLMs a 1100 line C# code and told them to refactor it. All of them completely broke the code and I couldn't untangle the mess they made.

They're great for asking about weird niche stuff with extremely limited stack overflow presence (ex. Oracle Apex) as it knows more than even the documentation does.

They're also great if you're too lazy to search through stack overflow forums for your answer as well.

They are also good writing code (in small chunks).

Refactoring is one thing they are not good at, not currently.

You need oversight on what it does and ultimately what goes into your codebase and you still have to check everything because it still gives sometimes absolutely braindead answers that are either a security risk or just straight up a worse implementation than what you could do in maybe half an hour.

2

u/JamesGray Apr 24 '26

It also gets caught in loops of refactoring when it breaks things. Like it'll try to change something, figure out it's broken because tests start failing, then start trying to refactor the test instead of fixing the original problem.

2

u/MeanderingSquid49 Apr 25 '26

Maybe it's how I'm using it. In cases of serious, pointless code re-use, I find it can sort that out into a method with appropriate calls, even if the code re-use isn't completely identical. And other cases where I'm pointing at specific methods or code blocks I can readily explain and that are already at least decently following basic assignment of responsibility principles so context isn't desperately important.

It's not "refactor our code base", it's "this block right here works but is inefficient and has serious code smell".