DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workkloads.

Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Blue Skies Ahead: An AI Case Study on LLM Use for a Graph Theory Related Application
  • From Zero to Production: Best Practices for Scaling LLMs in the Enterprise
  • My LLM Journey as a Software Engineer Exploring a New Domain
  • Unlocking AI Coding Assistants Part 3: Generating Diagrams, Open API Specs, And Test Data

Trending

  • How to Practice TDD With Kotlin
  • While Performing Dependency Selection, I Avoid the Loss Of Sleep From Node.js Libraries' Dangers
  • A Guide to Container Runtimes
  • Solid Testing Strategies for Salesforce Releases
  1. DZone
  2. Data Engineering
  3. AI/ML
  4. Unlocking AI Coding Assistants Part 1: Real-World Use Cases

Unlocking AI Coding Assistants Part 1: Real-World Use Cases

Dive into some AI coding assistant use cases and their effectiveness, highlighting their capabilities and limitations.

By 
Gunter Rotsaert user avatar
Gunter Rotsaert
DZone Core CORE ·
Apr. 21, 25 · Tutorial
Likes (1)
Comment
Save
Tweet
Share
2.2K Views

Join the DZone community and get the full member experience.

Join For Free

Do you think that AI coding assistants are not working for you? Do you constantly get the wrong responses and now you have given up using them? This blog will cover some use cases where AI coding assistants are helpful and will help you during your daily work. Enjoy!

Introduction

Nowadays, many AI coding assistants are available. These are demonstrated during conferences, in videos, described in blogs, etc. The demos are often impressive and it seems that AI is able to generate almost all of the source code for you, and all you need to do is review it. However, when you start using AI coding assistants at work, it just seems that it is not working for you and it only costs you more time. The truth lies somewhere in between. AI coding assistants can save you a lot of time for certain tasks, but they also have some limitations. It is important to learn which tasks will help you and how to recognize when you hit the limits of AI. Be aware that AI is evolving at a fast pace, so the limitations of today may be resolved in the near future.

In the remainder of this blog, some tasks are executed with the help of an AI coding assistant. The responses are evaluated and different techniques are applied which can be used to improve the responses when necessary. This blog is the first of a series, and more complex tasks will be covered in next blogs.

The tasks are executed with the IntelliJ IDEA DevoxxGenie AI coding assistant.

Two setups are used in this blog, and these used setups will be clearly mentioned:

  1. Ollama as inference engine and qwen2.5-coder:7b runs as a model. This runs on CPU only.
  2. LMStudio as inference engine and qwen2.5-coder:7b runs as a model. This runs on GPU only.

As you can see, local running models are used. Th reason for doing so is that you will hit the limits of a model earlier.

The reason for using two setups is because the tasks were started with setup 1. The assumption was that the only difference between CPU and GPU would be performance. However, after a while, it was discovered that a model running on a GPU also provides better responses.

The sources used in this blog are available at GitHub.

Prerequisites

Prerequisites for reading this blog are:

  • Basic coding knowledge
  • Basic knowledge of AI coding assistants,
  • Basic knowledge of DevoxxGenie

Task: Explain Kubernetes Yaml

The goal is to see whether AI can be helpful in explaining a Kubernetes yaml file or sections of it.

The setup: Ollama, qwen2.5-coder, CPU is used.

The Kubernetes yaml file contains a resources section which is not very clear to you.

YAML
 
...
          resources:
            requests:
              memory: "64Mi"
              cpu: "250m"
            limits:
              memory: "128Mi"
              cpu: "500m"
...


Prompt 1

Open the file, select the resources section and open a new chat window. Enter the following prompt:

Shell
 
/explain

DevoxxGenie will expand this to the following prompt:

Shell
 
Break down the code in simple terms to help a junior developer grasp its functionality.

Response

The response can be viewed here.

Response Analysis

This response is correct. The response talks about Mebibytes, but what are Mebibytes?

Prompt 2

Remain in the same chat window and enter the following prompt.

Shell
 
how much RAM is 64Mi and what is a mebibyte

Response

The response can be viewed here.

Response Analysis

The response is correct and the explanation accurately defines a Mebibyte.

Task: Explain Java Code

The goal is to see whether AI can be helpful in explaining Java code.

The setup LMStudio, qwen2.5-coder, GPU is used.

The Refactor class contains some complex logic and makes use of several other classes all located in the same package.

Prompt

Open the Refactor file, and add the entire source directory to the Prompt Context (right mouse click > context menu, and you are able to add an entire directory to the Prompt Context). Enter the following prompt:

PowerShell
 
/explain

DevoxxGenie will expand this to the following prompt:

Shell
 
Break down the code in simple terms to help a junior developer grasp its functionality.

Response

The response can be viewed here.

Response Analysis

This is a fairly good explanation of what this class is doing.

Task: Explain Regex

The goal of this task is to see whether or not AI can be helpful in explaining regular expressions.

The setup Ollama, qwen2.5-coder, CPU is used.

A common regex for password validation is available in file regex-1.txt.

Shell
 
^(?=.*[A-Z])(?=.*[a-z])(?=.*\d)(?=.*[!@#$%^&*])[A-Za-z\d!@#$%^&*]{8,20}$

Prompt 1

Open the file and enter the prompt:

Shell
 
/explain

DevoxxGenie will expand this to the following prompt.

Shell
 
Break down the code in simple terms to help a junior developer grasp its functionality.

Response

The response can be viewed here.

Response Analysis

The response is correct.

Maybe this was too obvious, let's try with a made up example.

Prompt 2

Open a new chat window.

Open file regex-2.txt. This file contains the following regular expression.

Shell
 
^\d{3}-[A-Z][a-z]{4}-\d{2}[a-z]{2}$

Enter the following prompt.

Shell
 
/explain

DevoxxGenie will expand this to the following prompt.

Shell
 
Break down the code in simple terms to help a junior developer grasp its functionality.

Response

The response can be viewed here.

Response Analysis

The response is correct.

Task: Explain Cron Expression

The goal of this task is to see whether AI can be helpful in explaining cron expressions. In the example, a cron expression for Spring Scheduling will be used. The important thing to notice is that Spring Scheduling cron expressions have an additional component to define the seconds. This is different from a regular crontab cron expression.

The setup Ollama, qwen2.5-coder, CPU is used.

The cron expression is located in a properties file.

Shell
 
application.cron-schedule=0 */15 * * * *

Prompt 1

Open the file, select the cron expression and enter the prompt:

Shell
 
/explain

DevoxxGenie will expand this to the following prompt:

Shell
 
Break down the code in simple terms to help a junior developer grasp its functionality.

Response

The response can be viewed here.

Response Analysis

It is recognized that it is a cron expression, but the explanation is not correct because this is a valid Spring Scheduling cron expression. However, the LLM assumed this was a crontab cron expression.

Prompt 2

Let's give the LLM a bit more context.

Remain in the same chat window in order that the chat history is sent to the LLM and enter the prompt.

Shell
 
explain the selected Spring Scheduling cron expression

Response

The response can be viewed here.

Response Analysis

The response is correct this time aside from the summary. So, by adding the information that it is about a Spring Scheduling cron expression, the LLM was able to explain it correctly.

Always be aware that you should provide enough context to the LLM, otherwise responses will not be what you would expect.

Task: Review Code

The goal with this task is to see whether or not AI can be helpful in reviewing code. Take a look at the following db.yml which is a Kubernetes deployment file taken from the Spring Petclinic.

When you take a look at this file, you will notice some issues with it:

  • the secret is hardcoded
  • no resource limits are added,\
  • the liveness and readiness probes are not quite ok

The setup Ollama, qwen2.5-coder, CPU is used.

Prompt 1

Open the db.yml file and use the following prompt:

Shell
 
/review

DevoxxGenie will expand this to the following prompt:

Shell
 
Review the selected code, can it be improved or are there any bugs?

Response

The response can be viewed here.

Response Analysis

The response is correct. However, an additional question arises: A comment is made about Secret Management, but not how this can be solved.

So, apply the suggested changes, they are located in file db-review.yml.

Prompt 2

Open this db-review.yml and enter a follow-up prompt in the same chat window (this way, the chat memory is sent to the LLM).

Shell
 
the secrets are hardcoded, I want to change this in order to adhere security best practices, what should be changed

Response

The response can be viewed here.

Response Analysis

The response is correct, although the db.yml file still contains a Secret section with the hardcoded values. This section should have been left out.

So, apply the suggested changes, they are located in file db-secret.yml and remove the Secrets section.

Conclusion

From the examples used in this blog, the following conclusions can be drawn:

  1. AI coding assistants are quite good at explaining different types of code, like Kubernetes yaml files, Java source code, regular expressions, cron expressions, etc.
  2. It is important to provide enough context to the LLM. For example:
    • When explaining Java code, it is very helpful when all used classes are sent in the Prompt Context.
    • When you want to explain a Spring Scheduling cron expression, you probably should tell the LLM this, otherwise it might assume that a crontab cron expression is used.
  3. AI coding assistants are quite good at reviewing code. This actually is quite similar as explaining code. However, you should always review the response before applying it and try to understand the response.
AI large language model

Published at DZone with permission of Gunter Rotsaert, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Blue Skies Ahead: An AI Case Study on LLM Use for a Graph Theory Related Application
  • From Zero to Production: Best Practices for Scaling LLMs in the Enterprise
  • My LLM Journey as a Software Engineer Exploring a New Domain
  • Unlocking AI Coding Assistants Part 3: Generating Diagrams, Open API Specs, And Test Data

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!