Using Too Much AI Generated Code in Projects

Using Too Much AI Generated Code in Projects

Hi everyone, it’s Ked. As I was contributing to an open source project a few months ago, I ran across an interesting issue. The project, which was created by developers fresh out of college or bootcamp, ran well, but was heavily reliant on AI-generated code. At first glance, using AI for coding might seem advantageous, thanks to its ability to produce correct code. However, the real test came when I tried to solve a simple responsive design issue in the header, turning into an absolute coding nightmare.


The header was composed of over 15 components, completely ignoring the DRY (Don't Repeat Yourself) principle, and the code comments mirrored the style typically generated by AI. There was also no style guide / coding standards document / contributing file, and as they all graduated from different universities, it was safe to assume that AI was being used for creating these components. This resulted in a chaotic mix of class names across components, despite them targeting identical CSS rules, making the task even more complicated.


The file structure was messy as well, with related header components (some not even titled ‘header’) scattered across the 'components' folder rather than being logically grouped in folders. I had to physically make a list of all the components that pertained to the header (some were labeled ‘header button component’ but were still used outside of the header!) to make sure that I had all the components in question. This was an absolutely terrible experience, and I don’t wish this AI spaghetti code on anyone!


As you can see, using AI to generate code is helpful, but can cause many issues, due to the AI’s inability to view the project's code holistically. Relying heavily on AI generated code is also a possible security risk, as automatically generated code might introduce security vulnerabilities, especially if the AI suggests outdated libraries or patterns. It requires the developers to have a strong understanding of security best practices to implement the suggestions properly.?


Another issue with AI generating code is that it always understands a solution, but not always the problem. This can get you stuck in a never ending loop where the solutions it gives doesn’t solve the issue at hand. From my experiences tutoring other junior developers, this “AI loop” is due to the lack of understanding the issue in the first place by the developer, as the developer can’t successfully explain the issue to an AI model. AI can’t solve what it doesn’t understand!


As someone who works closely with AI models, here is my personal recommendation: Do not use AI to solve issues directly, but use it to give you suggestions for solving those issues. Once you understand the solution (and more importantly, the problem!), it’s now up to you to implement the AI’s suggestions.?

Alison Faulkner

Data Design + Other Mischief

1 年

Neatly written article about a thorny issue- bravo!

回复
Brian Werner

Software Engineer | lover of tacos | RPG player

1 年

I couldn’t agree with this more! Thanks for sharing!

回复

要查看或添加评论,请登录

Kedgard Cordero的更多文章

  • Theme Switcher Elegance

    Theme Switcher Elegance

    Hi everyone, it’s Ked. I wanted to share a beautiful and efficient way of creating a light-dark mode feature I ran into…

  • Love-Hate Relationship With React.StrictMode

    Love-Hate Relationship With React.StrictMode

    Hi everyone, it’s Ked. I wanted to talk about my love-hate relationship with React.

  • Custom Cursor Conundrum: Open Source Contribution

    Custom Cursor Conundrum: Open Source Contribution

    I recently connected with a gentleman in India who was facing challenges with the custom cursor on his art gallery…

  • Effectively Protecting Your Routes

    Effectively Protecting Your Routes

    When working with any sort of route, whether using React Router or Next.js, it's crucial to secure your routes to…

  • Separating Backend Calls

    Separating Backend Calls

    Hi everyone, it's Ked. I'd like to share a quick folder structure tip that I've consistently observed in top-quality…

  • Metamorphosis: Transforming PDF Text into AI-Powered Intelligence

    Metamorphosis: Transforming PDF Text into AI-Powered Intelligence

    Hi everyone, it’s Ked. I wanted to share with you one of the most interesting and challenging processes I have ever…

  • When Standard Non-Relational Databases Aren't Enough

    When Standard Non-Relational Databases Aren't Enough

    Hi everyone, it's Ked. As I complete my latest freelance project regarding AI, I wanted to share with you an…

  • I Can’t Believe It’s Not ‘Human Empathy’

    I Can’t Believe It’s Not ‘Human Empathy’

    Hi everyone, it’s Ked. I wanted to share with you an interesting idea I have been thinking about and would love your…

    2 条评论
  • Shadcn UI, My New Favorite React Component Library

    Shadcn UI, My New Favorite React Component Library

    Hi everyone, it's Ked. I wanted to quickly share with you a fantastic React component Library that I have been using in…

  • Why I Am in Love With Clerk

    Why I Am in Love With Clerk

    As web development becomes more and more popular, authentication becomes more and more important. Building an…

社区洞察

其他会员也浏览了