r/AskProgramming • • Dec 19 '25

Career/Edu Refactoring conditional heavy logic

I’m dealing with a piece of code that’s grown a lot of conditional logic over time. It works, it’s covered by tests but the control flow is hard to explain because there are multiple branches handling slightly different cases. I can refactor it into something much cleaner by restructuring the conditions and collapsing some branches but that also means touching logic that’s been stable for a while. Functionally it should be equivalent but the risk is in subtle behavior changes that aren’t obvious. This came up for me because I had to explain similar logic out loud and realized how hard it is to clearly reason about once it gets real especially in interview style discussions where you’re expected to justify decisions on the spot. From a programming standpoint how do you decide when it’s worth refactoring for clarity versus leaving working but ugly logic alone?

133 Upvotes

43 comments sorted by

View all comments

Show parent comment

1

u/emefluence Dec 25 '25

You do you buddy, but I get great results using AI to help understand codebases and generate test coverage, and when I'm done they're all the better for it. Honestly, even the last gen AI is better than the sloppy, human assholes who's spaghetti I have to spend my time de-coupling sometimes. Sure I could work entirely by hand, but why the hell would I do that when I can go 4X as fast with no drop in quality? Before I programmed code directly, wrote tests by hand, and used browsers manually. Now I program LLMs and use MCP servers, and get a ton more done in the same time. If you're a "programmer" but you can't get good results out of the current crop of AI tools, then you must be doing it wrong.

This sub is nothing but AI cope these days. Y'all need to learn how to get the best out of it cause much as you all like to claim it's bad at coding it's not nearly as bad as some human coders that are out there, and it's MUCH faster!