Hands-On Amazon Q Developer Latest Features - /dev, /review, /doc, /test, /transform
AWS re:Invent 2024 brought with it a lot of surprises, one of them being big updates to its Generative AI (GenAI) assistant for software development, Amazon Q Developer. As hinted above, Amazon Q Developer is a GenAI assistant that tremendously accelerates development for developers by up to 80%. In this blog post, we'll look at the major new features of Amazon Q Developer and test them hands-on with a dummy Java project. These features are: /dev - to generate code for your feature. Supported languages are Java, Python, JavaScript, and TypeScript. /test - to generate unit tests for your code. Supported languages are Java (JUnit 4 and 5, JUnit Jupiter, Mockito) and Python (PyTest, Unittest). /review - to review your code for different types of code issues such as detecting security vulnerabilities in your code, detecting secrets, detecting issues with your IaC (Infrastructure as Code) files, detecting code quality issues, and more. Supports multiple languages, including those already listed for /dev. /doc - to generate documentation for your codebase. Supported languages are Java, Python, JavaScript, and TypeScript. /transform - to upgrade your Java and .NET projects. See this link for more details. Before proceeding, take note of this pricing info from the Amazon Q Developer web page: Try Amazon Q Developer free with the AWS Free Tier. The Amazon Q Developer Free Tier gives you 50 chat interactions per month. You can also use it to develop software 5 times per month or transform up to 1,000 lines of code per month. Prerequisites You can fork the Java 17 project in this repository to follow hands-on. If you have a lightweight Java 8 or Java 11 project, that would be better. In this article, we use Visual Studio Code and the Amazon Q extension (see the image below). However, you can also use Amazon Q Developer with the JetBrains IDE and Eclipse (still in preview) as well. After installing the extension, you can click the Amazon Q icon to open its chat window. Open the forked Java 17 project in your Visual Studio Code window before following the next steps. /dev - Generate a user authentication feature From the Amazon Q chat window, start typing /dev then select the option presented to you to open a /dev chat window. Next, prompt Amazon Q Developer to develop a user authentication feature. You'll see visual feedback informing you that Amazon Q Developer is generating code for the requested feature. Once the code is generated, you'll be able to peruse and accept the suggestions (or give feedback and request regeneration) And that's it, your user authentication feature is ready! /review - Detect issues with codebase Open a new Amazon Q chat window and start typing /review then select the option presented to you to open a /review chat window. We can then choose to review the workspace or just the active file in your Visual Studio Code window. Let's opt to review the workspace. Once the review is complete, we'll see a list of issues found and their severity. You can then use Amazon Q suggestions to optimize the code. /doc - Generate a README for our project Open a new Amazon Q chat window and start typing /doc then select the option presented to you to open a /doc chat window. We can then choose to create a new README or update an existing README. Our project has no README, we will create one. Once the README is created, we can either Accept the suggestion, Make changes to the suggestion, or Reject the suggestion. Let's accept the suggestion. We can now proceed to write a unit test for our project. /test - Write a unit test for a specific method Open a new Amazon Q chat window and start typing /test then select the option presented to you to open a /test chat window. The /dev step above created the class UserDetailsServiceImpl.java in the directory src/main/java/com/shesa/user/security/. I'll ask Amazon Q Developer to generate a unit test for the loadUserByUsername method in this class. We can then review the generated unit test and accept it if it looks good. /transform - Upgrade Java project (if using version 8 or 11) Open a new Amazon Q chat window and start typing /transform then select the option presented to you to open a /transform chat window. Given that our project is already using Java 17, we won't be able to transform its codebase. However, if you have a project using Java 8 or Java 11, you could use the /transform feature to upgrade it up to Java 17. That's it! I hope you find this useful. Don't hesitate to leave comments if you have any. Hasta la proxima!
![Hands-On Amazon Q Developer Latest Features - /dev, /review, /doc, /test, /transform](https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb2k2qehkvz3lzfzlef4l.png)
AWS re:Invent 2024 brought with it a lot of surprises, one of them being big updates to its Generative AI (GenAI) assistant for software development, Amazon Q Developer.
As hinted above, Amazon Q Developer is a GenAI assistant that tremendously accelerates development for developers by up to 80%.
In this blog post, we'll look at the major new features of Amazon Q Developer and test them hands-on with a dummy Java project.
These features are:
-
/dev
- to generate code for your feature. Supported languages are Java, Python, JavaScript, and TypeScript. -
/test
- to generate unit tests for your code. Supported languages are Java (JUnit 4 and 5, JUnit Jupiter, Mockito) and Python (PyTest, Unittest). -
/review
- to review your code for different types of code issues such as detecting security vulnerabilities in your code, detecting secrets, detecting issues with your IaC (Infrastructure as Code) files, detecting code quality issues, and more. Supports multiple languages, including those already listed for/dev
. -
/doc
- to generate documentation for your codebase. Supported languages are Java, Python, JavaScript, and TypeScript. -
/transform
- to upgrade your Java and .NET projects. See this link for more details.
Before proceeding, take note of this pricing info from the Amazon Q Developer web page:
Try Amazon Q Developer free with the AWS Free Tier. The Amazon Q Developer Free Tier gives you 50 chat interactions per month. You can also use it to develop software 5 times per month or transform up to 1,000 lines of code per month.
Prerequisites
You can fork the Java 17 project in this repository to follow hands-on. If you have a lightweight Java 8 or Java 11 project, that would be better.
In this article, we use Visual Studio Code and the Amazon Q extension (see the image below). However, you can also use Amazon Q Developer with the JetBrains IDE and Eclipse (still in preview) as well.
After installing the extension, you can click the Amazon Q icon to open its chat window.
Open the forked Java 17 project in your Visual Studio Code window before following the next steps.
/dev - Generate a user authentication feature
From the Amazon Q chat window, start typing /dev
then select the option presented to you to open a /dev
chat window.
Next, prompt Amazon Q Developer to develop a user authentication feature.
You'll see visual feedback informing you that Amazon Q Developer is generating code for the requested feature.
Once the code is generated, you'll be able to peruse and accept the suggestions (or give feedback and request regeneration)
And that's it, your user authentication feature is ready!
/review - Detect issues with codebase
Open a new Amazon Q chat window and start typing /review
then select the option presented to you to open a /review
chat window.
We can then choose to review the workspace or just the active file in your Visual Studio Code window. Let's opt to review the workspace.
Once the review is complete, we'll see a list of issues found and their severity. You can then use Amazon Q suggestions to optimize the code.
/doc - Generate a README for our project
Open a new Amazon Q chat window and start typing /doc
then select the option presented to you to open a /doc
chat window.
We can then choose to create a new README or update an existing README. Our project has no README, we will create one.
Once the README is created, we can either Accept the suggestion, Make changes to the suggestion, or Reject the suggestion. Let's accept the suggestion.
We can now proceed to write a unit test for our project.
/test - Write a unit test for a specific method
Open a new Amazon Q chat window and start typing /test
then select the option presented to you to open a /test
chat window.
The /dev
step above created the class UserDetailsServiceImpl.java
in the directory src/main/java/com/shesa/user/security/
. I'll ask Amazon Q Developer to generate a unit test for the loadUserByUsername
method in this class.
We can then review the generated unit test and accept it if it looks good.
/transform - Upgrade Java project (if using version 8 or 11)
Open a new Amazon Q chat window and start typing /transform
then select the option presented to you to open a /transform
chat window.
Given that our project is already using Java 17, we won't be able to transform its codebase. However, if you have a project using Java 8 or Java 11, you could use the /transform
feature to upgrade it up to Java 17.
That's it! I hope you find this useful.
Don't hesitate to leave comments if you have any.
Hasta la proxima!