How AI is Turning Your Codebase into a Dumpster Fireš„
There is a stealthy villain that is slowly wreaking havoc on your codebase. Itās a supervillain who is working against delivering features and squashing bugs. Pretty soon it might prevent even the best of us from getting a job in tech.
I think you know where this is going, so we need to figure out why AI is such an issue and what we can do about the problems it is bringing to our code.
The Symptom is the Problem
Many think that the biggest challenge in software development is tech debt, but theyāre barking up the wrong tree.
The biggest problem is code churn, where code is changed shortly after being written. Itās an indicator of wider issues while also being the cause of coding problems in itself.
AI use is correlated with an increase in code churn and by implication a decrease in code quality.
Iām going to say it. AI is destroying the quality of our code and creating great software is becoming more difficult due to its use. Thatās not the narrative youāve been hearing in the press, but I have evidence for this assertion.
A look at the evidence
The Paper
GitClear released a white paper about the impact AI code generation tools have had on the quality of code. In their study, they drawn on 150 million lines of code, so it seems they should know what they are talking about.
As the use of AI code generation has increased code churn (a metric used as a proxy for code quality) has increased.
The Implication
This seems to point to an important and worrying issue in software development. Iāve seen an increase in what I term ācopy and paste developmentā where software developers think they can take generated code (or that published on Stack Overflow for that matter) and put it into production with little or no changes.
Since developers who engage in this practice seldom truly understand the code they introduce, this often needs to be rewritten (often by the senior developers on their team).
This can happen because of the pursuit of coding speed as a metric to identify a good developer. As a metric developer velocity doesnāt measure typically measure the quality of code being pushed, or the complexity of the code. The measurement opens the door to poor coding practices, of which the overuse of AI is just one.
Speed != Quality
A Very Real Issue
When the junior developers adopt a āgo fasterā policy without being discerning about the quality of their code they contribute to a well known problem. Robert C. Martin (whom I seldom agree with) claims that code spends 10x more time being read than written, and this is demonstrative of the problem of going fast.
I feel in our team we need to clean up more bugs and spaghetti code than ever before, with Donāt Repeat Yourself (DRY) code becoming a rarity. I fought with the team recently that DRY tests are important (a class copy-pasted 10 times IIRC)āāāand the team pushed back that it is āeasier to modifyā replicated code. This āspeed at all costsā attitude is enabled by the use of AI.
AI Speed
AI doesnāt naturally contain coding values (like the DRY principle) as AI lacks visibility of the whole codebase (so cannot easily point out where code can be reused) and worse, AI is being sold on the promise it speeds development. Indeed, developers enjoy pushing code and delivering features for their teams, but this isnāt the universal win that it appears.
GitHub push their Copilot product with promises like code is written ā55% fasterā with Copilot. Speed feels like a metric that developers should prize, and in Agile completing work at a breakneck speed can make it look like a developer is in some respects āgoodā at their job without looking at the quality of code being produced.
I see the use of AI as encouraging less thoughtful coding as the quality of code nosedives as software development companies prize speed. As the job market for software engineers shrinks, Iām concerned that programmers are spitting out low quality code at a breakneck speed that then needs to be fixed by the few software engineers who care.
The Copy-Paste Allure
The copy-paste life. Previously a developer needed to trawl Stack Overflow to find some code that might solve their particular problem, whereas now a skilled AI prompt can solve that problem for you in double-quick time.
The problem is solved quickly, and the developer gets a dopamine hit from developing the feature. Everybody seems happy, and the work gets done. We are effectively equalizing the output of junior and senior developers in terms of speed (and acceptance rate, see below) but we are unable to equalize the quality of the code being pushed.
In my software development team, nobody seems to have the authority to remove duplicate code. Once I needed to remove an unreleased feature (behind a feature flag) and it took 3 JIRA tickets, testers were upset (how do we test this?) and the tech lead insisted on reading the pull requests line-by-line. It is this attitude to removing code which means our codebase is suffering since copy-pasting code in the codebase or from generative AI requires no such process. I think this is not just a tech debt issue, itās a cultural issue too.
Curing the āfire and forgetā developer
Putting that code into the codebase needs steely habits and a pinch of education. Rather than training AI to make āit dependsā decisions we can get developers of a higher standard.
I donāt mean rush a training program for developers, I mean develop a BOK and hold software developers accountable for their knowledge and performance. We need teams who understand the strategy that will produce maintainable code and the intelligence to solve problems in a quality way.
Then our senior developers will not need to invest so much time and effort in understanding poor code, and difficulties in maintaining that code. How about that?
Conclusion
As we navigate this AI-powered future, letās not lose sight of the principles that have long guided good software development: clarity, maintainability, and, above all, a commitment to quality. The journey ahead may be paved with AI, but itās the human touch that will ensure we reach our destination without compromising the integrity of our craftāā.