<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Massimo Deiana</title>
    <description>The latest articles on DEV Community by Massimo Deiana (@massimo_deiana_ccce73063a).</description>
    <link>https://dev.to/massimo_deiana_ccce73063a</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3557323%2F1d76a484-5683-4e02-b013-468522007088.jpg</url>
      <title>DEV Community: Massimo Deiana</title>
      <link>https://dev.to/massimo_deiana_ccce73063a</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/massimo_deiana_ccce73063a"/>
    <language>en</language>
    <item>
      <title>Will clean code principles remain relevant in the AI era?</title>
      <dc:creator>Massimo Deiana</dc:creator>
      <pubDate>Fri, 10 Oct 2025 11:43:34 +0000</pubDate>
      <link>https://dev.to/massimo_deiana_ccce73063a/will-clean-code-principles-remain-relevant-in-the-ai-era-bf7</link>
      <guid>https://dev.to/massimo_deiana_ccce73063a/will-clean-code-principles-remain-relevant-in-the-ai-era-bf7</guid>
      <description>&lt;p&gt;In the last few years, the rise of AI has completely changed how we envision the future of software development.&lt;br&gt;&lt;br&gt;
It started as a simple helper — a way to speed up repetitive tasks — but with the latest models, it’s clear that AI can be much more than that: a &lt;strong&gt;productivity booster&lt;/strong&gt;, a &lt;strong&gt;code reviewer&lt;/strong&gt;, or even a &lt;strong&gt;virtual pair-programming buddy&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Since it’s becoming obvious that most developers are now using AI in their daily workflow, it’s worth asking ourselves:  &lt;strong&gt;Do our current best practices still matter in this new era?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let’s explore that question through some well-known &lt;em&gt;Clean Code&lt;/em&gt; principles and see whether they remain relevant when working alongside AI.&lt;/p&gt;

&lt;p&gt;We’ll focus primarily on principles like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;SRP&lt;/strong&gt; (Single Responsibility Principle)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;DRY&lt;/strong&gt; (Don’t Repeat Yourself)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;YAGNI&lt;/strong&gt; (You Aren’t Gonna Need It)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;TDD&lt;/strong&gt; (Test driven development)&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 &lt;em&gt;Note: This article focuses mainly on the usage of agentic AI within IDEs — tools that can actively assist, refactor, and reason about your code in context.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;


&lt;h2&gt;
  
  
  SRP vs LOB
&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;Single Responsibility Principle (SRP)&lt;/strong&gt; has long been one of the cornerstones of &lt;em&gt;Clean Code&lt;/em&gt;. It encourages developers to keep each function or class focused on &lt;strong&gt;one purpose&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Sometimes, this principle has been pushed to extremes — In his book &lt;em&gt;Clean Code&lt;/em&gt; &lt;em&gt;Uncle Bob&lt;/em&gt; argued that functions should be &lt;strong&gt;as short as possible&lt;/strong&gt;, ideally just a few lines long&lt;/p&gt;

&lt;p&gt;However, modern development practices have introduced a counter-trend: &lt;strong&gt;Locality of Behavior (LOB)&lt;/strong&gt;.&lt;br&gt;&lt;br&gt;
Frameworks like &lt;strong&gt;React&lt;/strong&gt; and &lt;strong&gt;Tailwind CSS&lt;/strong&gt; naturally encourage colocating logic, styling, and data fetching within a single component. Instead of scattering behavior across multiple files, developers now value keeping &lt;strong&gt;everything needed for a feature in one place&lt;/strong&gt;, making it easier to reason about and modify.&lt;/p&gt;

&lt;p&gt;When you work with AI tools, the quality of their output depends heavily on the &lt;strong&gt;context you provide&lt;/strong&gt;. You usually have to give the model the files relevant to your task — and every additional file increases &lt;strong&gt;token usage&lt;/strong&gt;, &lt;strong&gt;cost&lt;/strong&gt;, and &lt;strong&gt;noise&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;With a strong SRP design:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Each file or function serves a single, well-defined purpose.&lt;/li&gt;
&lt;li&gt;You can confidently include only the relevant files in your AI context.&lt;/li&gt;
&lt;li&gt;The model doesn’t waste tokens reading unrelated styling or data logic.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let’s take the following React component that fetches to-dos from an API and displays them with Tailwind styling.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;//TodoList.tsx&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;TodoList&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;todos&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setTodos&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Todo&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;([]);&lt;/span&gt;

  &lt;span class="nf"&gt;useEffect&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://api.example.com/todos&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
      &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;setTodos&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;[]);&lt;/span&gt;

  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;ul&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;p-4 space-y-2&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;todos&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;todo&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;li&lt;/span&gt;
          &lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;todo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
          &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;`p-2 rounded &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;
            &lt;span class="nx"&gt;todo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;completed&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;bg-green-100&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;bg-gray-100&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
          &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
          &lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Clicked: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;todo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;text&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;
        &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;todo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;text&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/li&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="p"&gt;))}&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/ul&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now imagine you need to change the API endpoint to &lt;code&gt;/v2/todos&lt;/code&gt;.&lt;br&gt;&lt;br&gt;
If you ask an AI model to do that, you have to provide &lt;strong&gt;this entire file&lt;/strong&gt; — including UI and styling — just so it can modify one line inside the &lt;code&gt;fetch&lt;/code&gt; call.&lt;br&gt;&lt;br&gt;
That’s inefficient and increases the chance the model might accidentally alter unrelated parts of your component.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// useTodos.ts&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;fetchTodos&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Todo&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://api.example.com/todos&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With this structure, the fetching logic lives in &lt;code&gt;useTodos.ts&lt;/code&gt;.&lt;br&gt;&lt;br&gt;
If you want the AI to update the API endpoint, you only need to provide &lt;strong&gt;that one small file&lt;/strong&gt;. That means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Less context&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Less noise&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Clearer intent&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This example is intentionally small, but in a large codebase the impact compounds dramatically.&lt;br&gt;&lt;br&gt;
A single change — like updating an endpoint, adjusting a data format, or modifying a service call — might otherwise require passing dozens of mixed-concern files to the AI.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In other words:&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;SRP doesn’t just make code easier for humans to maintain — it makes it &lt;strong&gt;easier for AI to understand and modify accurately&lt;/strong&gt;, because each file or module has a clear, focused purpose.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  DRY Principle
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Don’t Repeat Yourself (DRY)&lt;/strong&gt; is a principle aimed at reducing repetition of information across a system.&lt;br&gt;&lt;br&gt;
Its core idea is simple: a single change in your logic should require a change in &lt;strong&gt;only one place&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Traditionally, this made code easier to maintain and less error-prone.&lt;br&gt;&lt;br&gt;
But with AI-assisted development, does DRY still matter if an AI can perform massive refactorings in seconds?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Actually, it matters even more.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When you ask an AI model to update or refactor your code, it only “sees” the files you include in context.&lt;br&gt;&lt;br&gt;
If you’ve duplicated logic across multiple files and forget to include one of them, that part simply won’t be updated — leaving you with inconsistent behavior.&lt;/p&gt;

&lt;p&gt;You &lt;em&gt;could&lt;/em&gt; technically index your entire codebase and feed it all to the AI, but that’s:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;time-consuming,&lt;/li&gt;
&lt;li&gt;expensive in tokens, and&lt;/li&gt;
&lt;li&gt;riskier — because the more context you give, the more the model can &lt;strong&gt;hallucinate&lt;/strong&gt; or make unrelated edits.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By keeping your code DRY, you reduce the surface area the AI has to understand.&lt;br&gt;&lt;br&gt;
One source of truth means one place to update — whether the change comes from you or from an automated assistant.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In other words:&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;DRY doesn’t just prevent human mistakes anymore — it prevents &lt;em&gt;AI mistakes too.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  YAGNI
&lt;/h2&gt;

&lt;p&gt;YAGNI — &lt;em&gt;You Aren’t Gonna Need It&lt;/em&gt; — is a principle that’s probably caused me the most trouble when working with AI.&lt;/p&gt;

&lt;p&gt;Imagine you’ve developed an interface with multiple conversion methods, but you only need the first one. You might have added the others “just in case.”&lt;br&gt;&lt;br&gt;
From my experience, AI tools often try to use those extra methods, even though they’re irrelevant. The result? Your codebase grows in &lt;strong&gt;complexity with features you don’t actually need&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The same applies when your requirements are vague. If your prompt doesn’t clearly define the scope of what needs to be done, the AI may try to handle &lt;strong&gt;edge cases or scenarios that are unnecessary&lt;/strong&gt;, adding more code than required.&lt;/p&gt;

&lt;p&gt;That’s why it’s crucial to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Review AI-generated code carefully&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Ask yourself if it’s relevant&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Remove or ignore parts that aren’t needed&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;In other words:&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;YAGNI doesn’t just protect humans from over-engineering — it protects AI-assisted development from generating unnecessary complexity, keeping your codebase focused and maintainable.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  The Impact of TDD
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Test-Driven Development (TDD)&lt;/strong&gt; is a methodology highly praised in the developer community, yet the majority of developers still write tests &lt;strong&gt;after&lt;/strong&gt; the production code.&lt;/p&gt;

&lt;p&gt;Nowadays, it’s common to see developers &lt;strong&gt;generating unit tests using AI&lt;/strong&gt; based on existing code. This is a trap you should avoid. AI-generated tests will almost always &lt;strong&gt;validate the code as it exists&lt;/strong&gt;, rather than validating the &lt;strong&gt;requirements&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Remember: the goal of automated testing is &lt;strong&gt;to ensure that your code meets the intended requirements&lt;/strong&gt; and &lt;strong&gt;prevents regressions&lt;/strong&gt; when changes are made — not just to check that the code “works as written.”&lt;/p&gt;

&lt;h3&gt;
  
  
  TDD and AI
&lt;/h3&gt;

&lt;p&gt;When combined with AI, TDD offers a clear advantage: it &lt;strong&gt;defines the scope&lt;/strong&gt; of what should be generated.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You write tests that capture &lt;strong&gt;exactly what the behavior should be&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;AI generates code to satisfy those tests&lt;/li&gt;
&lt;li&gt;This prevents unnecessary or irrelevant code from being created&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;However, this only works if your tests are &lt;strong&gt;well-written and meaningful&lt;/strong&gt;. Poor tests can create a &lt;strong&gt;false sense of security&lt;/strong&gt;: the AI (or you) might make changes that break requirements, but because the tests still pass, you wouldn’t notice.&lt;/p&gt;

&lt;p&gt;To mitigate this risk, consider &lt;strong&gt;mutation testing&lt;/strong&gt; — a technique that intentionally introduces faults into your code to check if your tests catch them. This ensures your tests are actually &lt;strong&gt;capable of detecting errors&lt;/strong&gt;, reinforcing confidence in both your code and the AI-generated output. There are great tools that automate this process, such as &lt;strong&gt;PIT&lt;/strong&gt; for Java or &lt;strong&gt;Stryker&lt;/strong&gt; for JavaScript, which make mutation testing accessible even in large projects.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In other words:&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;TDD doesn’t just guide humans — it guides AI. Well-written tests define the desired behavior, prevent over-engineering, and ensure that both developers and AI work safely within the intended scope.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Set the Standard
&lt;/h2&gt;

&lt;p&gt;Even though principles like SRP, DRY, and YAGNI are widely discussed in the developer community, they are &lt;strong&gt;far from universal in existing codebases&lt;/strong&gt;.&lt;br&gt;&lt;br&gt;
This matters when using AI: LLMs are trained on vast amounts of code, much of which &lt;strong&gt;doesn’t follow the clean code principles you might consider acceptable&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;To avoid generating “bad code,” one technique that has worked well for me is &lt;strong&gt;providing examples of what I consider clean&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Let's take React as an example. Many developers mix &lt;strong&gt;UI, data fetching, and logic&lt;/strong&gt; in a single component. I personally prefer a structure that separates concerns:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;API client&lt;/strong&gt; for all requests&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Custom hooks&lt;/strong&gt; for handling operations&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Styled components&lt;/strong&gt; in separate files&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;main component&lt;/strong&gt; that orchestrates everything&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is likely &lt;strong&gt;not the default structure an LLM would propose&lt;/strong&gt;. To guide it toward my standard, I start by &lt;strong&gt;prompting the AI to build the feature piece by piece&lt;/strong&gt;, rather than asking it to generate an entire screen at once (e.g., “Create a CRUD screen for Product”).&lt;/p&gt;

&lt;p&gt;Once the structure is in a shape I like, I can &lt;strong&gt;provide these components as context/examples&lt;/strong&gt; for the LLM to follow in future generations. Over time, this effectively trains the AI to &lt;strong&gt;adhere to your personal coding standards&lt;/strong&gt;, improving both quality and consistency.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In other words:&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;You can teach AI your standards the same way you teach a junior developer: by &lt;strong&gt;showing examples, guiding step by step, and providing clear context&lt;/strong&gt;. This ensures the code it generates aligns with the structure and quality you expect.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;It’s tempting to think that with AI, clean code principles might become less relevant — that the model will “figure everything out” and fix problems automatically.&lt;br&gt;&lt;br&gt;
While this might hold true for &lt;strong&gt;small, isolated codebases&lt;/strong&gt;, the reality changes as your system grows in &lt;strong&gt;size and complexity&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;When companies demonstrate their AI tools, they often focus on &lt;strong&gt;speed and simplicity&lt;/strong&gt;, not on &lt;strong&gt;sustainable architecture&lt;/strong&gt;. The examples shown — a to-do app built in minutes — don’t reflect the challenges of &lt;strong&gt;real-world software&lt;/strong&gt;, where understanding the full context and maintaining the system long-term is crucial.&lt;/p&gt;

&lt;p&gt;In practice, your job isn’t to build a toy app from scratch; it’s to build and maintain large, evolving systems — systems where &lt;strong&gt;only you truly understand the intent, the domain, and the trade-offs&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;That’s why clean code principles and good practices are &lt;strong&gt;more important than ever before&lt;/strong&gt;.&lt;br&gt;&lt;br&gt;
They don’t limit what AI can do — they &lt;strong&gt;guide it&lt;/strong&gt;, ensuring that the code it generates remains understandable, maintainable, and aligned with your vision.&lt;/p&gt;

</description>
      <category>cleancode</category>
      <category>ai</category>
      <category>programming</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
