<?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: ModernCpp</title>
    <description>The latest articles on DEV Community by ModernCpp (@moderncpp).</description>
    <link>https://dev.to/moderncpp</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%2F165931%2F20efd849-a403-4928-802b-dd61e140372d.png</url>
      <title>DEV Community: ModernCpp</title>
      <link>https://dev.to/moderncpp</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/moderncpp"/>
    <language>en</language>
    <item>
      <title>5 Powerful Tips to Generate Better Code with AI</title>
      <dc:creator>ModernCpp</dc:creator>
      <pubDate>Wed, 11 Feb 2026 22:50:09 +0000</pubDate>
      <link>https://dev.to/moderncpp/5-powerful-tips-to-generate-better-code-with-ai-55eg</link>
      <guid>https://dev.to/moderncpp/5-powerful-tips-to-generate-better-code-with-ai-55eg</guid>
      <description>&lt;p&gt;This isn’t another &lt;em&gt;“how to prompt AI”&lt;/em&gt; post.&lt;/p&gt;

&lt;p&gt;This is about &lt;strong&gt;lesser-known habits&lt;/strong&gt; that dramatically improve the &lt;strong&gt;quality of code&lt;/strong&gt; you get from LLMs.&lt;/p&gt;




&lt;h2&gt;
  
  
  Tip 1 — Say you’re not satisfied (immediately)
&lt;/h2&gt;

&lt;p&gt;If the generated code isn’t what you expected, &lt;strong&gt;say it clearly and early&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why this works
&lt;/h3&gt;

&lt;p&gt;LLMs adapt &lt;em&gt;within the conversation&lt;/em&gt;.&lt;br&gt;&lt;br&gt;
When you signal dissatisfaction, you push the model to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reconsider assumptions
&lt;/li&gt;
&lt;li&gt;Apply stricter reasoning
&lt;/li&gt;
&lt;li&gt;Explore alternative approaches
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Very often, &lt;strong&gt;the second answer is far more thoughtful&lt;/strong&gt; than the first.&lt;/p&gt;

&lt;p&gt;Don’t accept “almost right” code. Push back.&lt;/p&gt;




&lt;h2&gt;
  
  
  Tip 2 — Ask twice (even when it’s good)
&lt;/h2&gt;

&lt;p&gt;Even if the solution works, try this:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;“Improve this code.”&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You’ll be surprised how often AI will:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Simplify logic
&lt;/li&gt;
&lt;li&gt;Improve naming
&lt;/li&gt;
&lt;li&gt;Enhance performance
&lt;/li&gt;
&lt;li&gt;Reduce edge-case risk
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Iterating with AI is like having a &lt;strong&gt;senior reviewer on demand&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Tip 3 — Give the big picture (real context matters)
&lt;/h2&gt;

&lt;p&gt;AI performs &lt;em&gt;dramatically better&lt;/em&gt; when it understands your architecture.&lt;/p&gt;

&lt;p&gt;Instead of:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Write a method that does X”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Try:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“This belongs to the service layer. We use a layered architecture:&lt;br&gt;&lt;br&gt;
Controller → Service → Repository. Where should this logic live?”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Now the AI can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Place responsibilities correctly
&lt;/li&gt;
&lt;li&gt;Avoid leaking business logic into technical layers
&lt;/li&gt;
&lt;li&gt;Produce code that fits your design
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  The real power move
&lt;/h3&gt;

&lt;p&gt;Instead of describing the system manually, use an &lt;strong&gt;AI Prompt Builder&lt;/strong&gt; that injects &lt;strong&gt;real project context&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;For example, tools like &lt;a href="https://www.cppdepend.com/features/ai-promptbuilder" rel="noopener noreferrer"&gt;CppDepend’s AI Prompt Builder&lt;/a&gt; — a feature that generates reliable, context-aware prompts using:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Dependencies between components
&lt;/li&gt;
&lt;li&gt;Layer violations
&lt;/li&gt;
&lt;li&gt;Code metrics (complexity, size, coupling…)
&lt;/li&gt;
&lt;li&gt;Type relationships &amp;amp; call graphs
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That context can be added to the prompt so the AI doesn’t guess — it understands your system’s structure.&lt;/p&gt;

&lt;p&gt;Now AI isn’t just generating code.&lt;/p&gt;

&lt;p&gt;It becomes an &lt;strong&gt;architecture-aware assistant&lt;/strong&gt; working with real project data.&lt;/p&gt;




&lt;h2&gt;
  
  
  Tip 4 — Step away and refactor yourself
&lt;/h2&gt;

&lt;p&gt;After generating multiple AI-driven methods, &lt;strong&gt;pause&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;AI optimizes &lt;em&gt;locally&lt;/em&gt;, not &lt;em&gt;globally&lt;/em&gt;. You still must:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reorganize classes
&lt;/li&gt;
&lt;li&gt;Merge duplicated logic
&lt;/li&gt;
&lt;li&gt;Extract shared abstractions
&lt;/li&gt;
&lt;li&gt;Clean design inconsistencies
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;AI accelerates coding.&lt;br&gt;&lt;br&gt;
&lt;strong&gt;You are still the architect.&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Tip 5 — Ask AI to criticize its own code
&lt;/h2&gt;

&lt;p&gt;This is one of the most underrated tricks.&lt;/p&gt;

&lt;p&gt;After the code is generated, ask:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;“What are the weaknesses of this code?”
&lt;/li&gt;
&lt;li&gt;“Where could this fail in production?”
&lt;/li&gt;
&lt;li&gt;“What edge cases are missing?”
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now the AI switches roles:&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Creator → Reviewer&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This often reveals:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Hidden bugs
&lt;/li&gt;
&lt;li&gt;Performance risks
&lt;/li&gt;
&lt;li&gt;Missing validations
&lt;/li&gt;
&lt;li&gt;Concurrency issues
&lt;/li&gt;
&lt;li&gt;Security gaps
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You essentially get a &lt;strong&gt;free design review&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Final Thought
&lt;/h2&gt;

&lt;p&gt;AI doesn’t replace engineering judgment — it &lt;strong&gt;amplifies&lt;/strong&gt; it.&lt;/p&gt;

&lt;p&gt;The best workflow looks like this:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Generator → Improver → Critic → Assistant&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;…while &lt;strong&gt;you remain the architect&lt;/strong&gt;.&lt;/p&gt;

</description>
      <category>ai</category>
    </item>
    <item>
      <title>Focus on the developer skills and not only on the code quality.</title>
      <dc:creator>ModernCpp</dc:creator>
      <pubDate>Wed, 13 Sep 2023 20:01:25 +0000</pubDate>
      <link>https://dev.to/moderncpp/focus-on-the-developer-skills-and-not-only-on-the-code-quality-46m7</link>
      <guid>https://dev.to/moderncpp/focus-on-the-developer-skills-and-not-only-on-the-code-quality-46m7</guid>
      <description>&lt;p&gt;When we want to improve the code quality of a project we try to evaluate the code to detect if it’s well designed, well implemented and very well tested. After the analysis using the existing tools or even by a review from an expert we can get a report of what needs to be improved in the code to assure a delivery of a release with a minimum of issues.&lt;/p&gt;

&lt;p&gt;But wait, who is the origin of the code? It’s a development team, each one has its responsibility. We can have an architect, the designers, the developers and the testers. And what matters more than the code is the team skills involved in the project, don’t forget that a bad architect could ruin your project even if you have excellent developers.&lt;/p&gt;

&lt;p&gt;During the development process of a project try to elevate the development team skills by detecting regularly their weaknesses and correct them as soon as possible to avoid making the same mistakes for their next development tasks.&lt;/p&gt;

&lt;p&gt;There are many tools that can help the developers to improve their code quality, many of them focus on the code and not on the developer skills. Scanyp is a highly customisable solution to adapt it to your needs to focuses more on the team skills. And It’s free for the projects less than 500K lines of code.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.scanyp.com"&gt;Scanyp&lt;/a&gt; offers a comprehensive evaluation of the team’s development proficiency across various categories, encompassing code implementation, design, unit testing, and code documentation. What effectively contributes to code quality improvement.&lt;/p&gt;

&lt;p&gt;After the analysis using Scanyp the dashboard give us the whole picture about the skills scores and what more interesting is their evolutions, to check if the developers increase their skills or not:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0fi8up9nzhnh78dngl63.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0fi8up9nzhnh78dngl63.png" alt="Scanyp Dashboard" width="720" height="567"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;However from the team skills page we have the details per category:&lt;/p&gt;

&lt;h2&gt;
  
  
  Code implementation score:
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5l6zb8vmdaivm7c1hgho.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5l6zb8vmdaivm7c1hgho.png" alt="Code Implementation" width="720" height="249"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This score is calculated from the following scores:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The maintainability score which gives an approximation about the maintainability of the project.&lt;/li&gt;
&lt;li&gt;The naming score is calculated from the rules detecting the violation of the names against the most known coding standard naming conventions of the programming language concerned. Of course you can from the admin area change these rules to match your chosen naming conventions.&lt;/li&gt;
&lt;li&gt;The clones score which is calculated from the number of the clones detected in the source code&lt;/li&gt;
&lt;li&gt;The code smells score which is calculated from the code smells detected in the code, and as many parameters in Scanyp we can also change the code smells parameters from the admin area to match our expectations. For example by default scanyp considers that a type is big if LOC&amp;gt;500. However, you can change this threshold from the script function of this query. These rules are grouped in the code smells group.&lt;/li&gt;
&lt;li&gt;Compliance with the implementation rules which is calculated from the code implementation violated rules, And also you can modify as you want the rules provided by default concerning the implementation.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Note that all the numbers are clickable to have exactly where the problems are in the code.&lt;/p&gt;

&lt;h2&gt;
  
  
  The design score:
&lt;/h2&gt;

&lt;p&gt;This score gives us a whole picture about the design of your project:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fph18283v4ob7brvesm2e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fph18283v4ob7brvesm2e.png" alt="Design" width="720" height="183"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This score is calculated from the following scores:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Coupling score which is calculated from the most coupled types methods in the code base. If many types and methods are highly coupled this score become low,&lt;/li&gt;
&lt;li&gt;Cohesion score which is calculated from the not cohesive types found in the project. If many types have a low cohesion, the score becomes low.&lt;/li&gt;
&lt;li&gt;Design smells score which is calculated from the violated design rules, And like the code implementation smells we can easily change the design smells rules.&lt;/li&gt;
&lt;li&gt;Rules compliance which is calculated from the violated design rules, And also you can modify as you want the rules provided by default concerning the design.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The bug free score:
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6apob2uf86ffrv1h19dx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6apob2uf86ffrv1h19dx.png" alt="Bug score" width="720" height="184"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This score gives us a whole picture about the issues detected in your project:&lt;/p&gt;

&lt;p&gt;This score is calculated from the number of the issues detected. However the weight of an issue is proportional to its severity. Which means that you can have a low score if only 20 critical issues are detected and a good score even if you have 100 low issues detected.&lt;/p&gt;

&lt;h2&gt;
  
  
  The unit testing score:
&lt;/h2&gt;

&lt;p&gt;Which represents the coverage percent of the project.&lt;/p&gt;

&lt;h2&gt;
  
  
  The documentation score:
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnix32x0v4no2cdvg4dxw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnix32x0v4no2cdvg4dxw.png" alt="Doc score" width="720" height="229"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This score gives us a whole picture about the documentation of the public types and methods of your project:&lt;/p&gt;

&lt;p&gt;This score is calculated from the following scores:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Comments on public big methods and types : The documentation is needed for big types and methods. Indeed for small methods no need to affect the score if a documentation is not found.&lt;/li&gt;
&lt;li&gt;Comments on public complex methods : For complex methods it is recommended to have documentation, and no need to affect the score if a not complex method with no documentation is detected.&lt;/li&gt;
&lt;li&gt;Comments on interfaces/ abstract types: These kind of types are destined to be used as an API and it’s mandatory to have a documentation for each method exposed, so the user knows exactly what this method does.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To resume, as a team member try to focus to elevate your skills to avoid repeating the same mistakes, what effectivly contribute to have a high quality code.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
