r/ProgrammerHumor • • 13d ago

Meme thoseCodingEra

Post image
24k Upvotes

822 comments sorted by

View all comments

Show parent comment

2

u/gh0strom 12d ago

Just gotta ask the LLM to read and learn how your existing code base is written. Then ask it to generate code that matches the design patterns it saw in your code. I had the same problem in a project I was working on and I just had to teach it a bit. Not being condescending here, but you might want to learn some LLM best practices to get the most out of it.

3

u/atxgossiphound 11d ago edited 11d ago

Been there, done that (recently, too, as in Fable 5.2). It sometimes works, but isn't consistent and requires more corrective prompts than just doing it yourself.

Here's the thing with a well architected codebase with good abstractions: most bug fixes and new features are just a few lines of code. Like under 10.

LLMs, even the new ones, struggle understand the architecture enough to know how to add those few lines of code. Instead, they add 50 or 100 that, while they might do the same thing, introduce new code that replicates something that can be done more concisely and correctly (relative to the architecture) by using the existing libraries, abstractions, and patterns.

That can lead to downstream issues when you refactor and don't realize that two sections of code do the same thing. With good abstractions, you fix it once. With flat code, you have to find it everywhere, or trust that the LLM finds it everywhere.

I deal with this regularly with our one dev who likes to use LLMs. It'll spit out a bunch of code and rationale for a change that totally missed how the overall system works (even with good docs and corrective prompting). Every time, we end up throwing away his LLM code and tweaking the few lines of code to do it right.

Study software architecture and good software engineering practices and watch how LLMs don't follow them very well. Generating idiomatically correct code and having deep unit test coverage is not the same as good architecture and engineering.