I'm a lazy developer. Here's how Amazon Q is enabling me
Tags: productivity, ai, aws
Published: 2024-06-18 19:27:06

I'm always on the hunt for ways to improve my productivity as a developer. I've spent the better part of the last two weeks diving head first into using [Amazon Q Developer](https://aws.amazon.com/developer/generative-ai/amazon-q), experimenting with how it might work in my development flow, learning the ins and outs, and chatting with coworkers about how they are using it. Today, I want to share what I've learned so far, how I'm tweaking my productivity and [staying in the flow](https://github.blog/2024-01-22-how-to-get-in-the-flow-while-coding-and-why-its-important/). 
 
## Reduce my context switching

When I'm writing code, I want to get in the flow and stay in the flow. [Context switching](https://leaddev.com/process/managing-chaos-context-switching) -- flipping between apps, back and forth between browser tabs, a google search here, and StackOverflow search there, the ding of an email, a bleep of a Slack notification (oops, I'm late for a meeting) -- all of this [comes with a cost](https://news.ycombinator.com/item?id=35459333).

I'm finding that Amazon Q Developer keeps me in my IDE. Instead of hopping over to a browser to do a google search or to read through documentation for my programming language, the framework I'm using, or the AWS docs, I can use this tool to do this digging for me.

I can ask how to get started with a new project. Here, I started with the prompt `What are the steps to creating a python Flask app?` Amazon Q Developer outlines the steps I need to take to get started, providing me with both code snippets and explanations.

![Amazon Q chat with prompt "What are the steps to creating a python Flask app?" and a response.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lbf53hg3u0cl6ya4xt86.png)

I can never remember the steps to create a python virtual environment so I ask it questions like `How do I initialize a python virtual environment?`

![Amazon Q chat with prompt "How do I initialize a python virtual environment?"](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3xg2ja20wi1e1tqahjgm.png)

And if I want to go deeper, I'm even presented with external references backing up the responses.

![The sources used to prepare the response.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d4f86hpcauj05mokwkhp.png)

All of this allows me to stay in my IDE, reducing my context switching, and stay in the flow. Check out how my colleague [stays in the flow with Amazon Q](https://community.aws/content/2fo810EHkduTy0eRQRfxCmEFX10/using-amazon-q-developer-in-my-development-flow).

## Support for my lazy developer mentality

According to the creator of the Perl programming language, Larry Wall, laziness is one of the virtues of a good programmer. For a programmer to be effective and efficient, they must also be lazy. But not in the traditional, lounge on your couch and watch TV all day and be lazy sense. Instead, a lazy developer is interested in saving time, automating tasks, especially the boring, time consuming, or brittle ones, documenting work for others.

That's me. I'm a lazy developer.

I don't remember all the properties for an HTML text area. So I ask Amazon Q to do the research for me and propose examples for boilerplate code like HTML elements and unit tests.

![Amazon Q chat with prompt "What is the syntax for an HTML textarea?"](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a1bb9vdvbam37cnq7czg.png)

I ask it to explain a block of code by selecting it and then using the "Send to Amazon Q" menu option:

![The Send to Amazon Q -> Explain menu.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/93hbjyhh9cnl8vaacsx5.png)

And the response I get back:
![Prompt "Explain the following part of my code:" and the selected code.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cytl5o1klp60x6kazvrx.png)

And then I wanted more detail on the `json.loads` line:
![Prompt "Explain the following part of my code:" and the selected code.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rup3ffgkhff5ygyxyxoy.png)

In a previous life, I often worked as a team of one, inheriting someone else's codebase. I would come into a new codebase with no other teammates to help me figure out what was going on. This is where Amazon Q can help you get up to speed quickly, summarizing blocks of code, functions, or even whole files.

## Help me debug
One challenging task for developers is debugging hairy bugs. It's hard because you end up having to shove a bunch of info into your short term memory in order to trace through layers and layers of code, some of which you may not even be familiar with. Then... BAM! Slack notification, time for a meeting! You drop everything for an hour and come back to debugging and have to start that trace over again. Or you're chasing through multiple API docs trying to figure out whether you've correctly understood how to make a call and which parameters to send and how to handle the response.

That's exactly what just happened to me as I was trying to make a call to Amazon Bedrock's `invoke_model` API.

I messed it up! So I asked Amazon Q for an assist:
![Asking Q chat to help me debug the error.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uuxwvhx1x9p0p45degg6.png)

I had also messed up the format of the response body, so I used Amazon Q to help me debug through that as well:

![Prompt "What is the format of the prompt I need to send to Bedrock with invoke_model"](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cfw7ne7mxrj4h6b2bsst.png)

It's important to recognize that LLMs are backing Amazon Q, which means it will experience hallucinations just like any other model. I did have some extra debugging because of this as the example code proposed using `ModelId` and `Body` when calling `invoke_model` when they should have been lower-case `modelId` and `body`.

Want to see more complex debugging scenarios with Amazon Q? Check out my colleagues' experiences solving a [data serialization problem](https://community.aws/content/2fbWIDtx027BQjqmNNSA2R7sTqI/kafka-go-and-protocol-buffers-how-amazon-q-solved-a-nasty-data-deserialization-problem) and [finding and fixing a concurrency bug](https://community.aws/content/2fbDOb7FOMzJJgTdhmCam7DVW1s/ai-found-a-concurrency-bug-in-this-code-then-fixed-it).

## Help me write tests
I am an avid tester, so when I'm writing code, I'm often pairing it up with unit tests at a minimum. I have not had much experience using mocks in Python tests, so I asked Q `How would you write a test for the send_prompt_to_bedrock function using mocks?` and got this response:

![Prompt "How would you write a test for send_prompt_to_bedrock using mocks?"](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9ellabgt38follcvw3gf.png)

It gets me a lot closer than had I started with a google search, dug through some documentation, and started by writing the boilerplate code myself. This response is an example customized to what I am doing, so I don't have to try to translate what one blog post author was trying to do in their situation to what I'm trying to do in my situation. I didn't spend much time getting this test to pass, most of my time was making sure the request/response objects were prepared correctly.

Read more about how my colleagues are using Amazon Q for [writing tests earlier](https://community.aws/content/2gBZtC94gPzaCQRnt4P0rIYWuBx/shift-left-workload-leveraging-ai-for-test-creation) and for [test driven development](https://community.aws/content/2freQx3PAGvuHlULJ2kJ57WP34E/test-driven-development-with-amazon-q-developer).

## Wrapping up
Hopefully the only thing you took away from this article wasn't that I'm a lazy developer! Here, I covered four different ways I'm tweaking my productivity as a developer so I can stay in the flow:
1. I'm reducing my context switching by staying in my IDE
2. I'm getting support for my lazy developer mentality by generating boilerplate code, summarizing what code is doing, and getting help with refactoring
3. I'm delegating my debugging work
4. I'm getting help with writing my unit tests

Are you ready to get started with Amazon Q Developer in your IDE? Check out how to set it up for [VS Code](https://community.aws/content/2fVw1hN4VeTF3qtVSZHfQiQUS16/getting-started-with-amazon-q-developer-in-visual-studio-code) or [JetBrains IDEs](https://community.aws/content/2fXj10wxhGCExqPvnsJNTycaUcL/adding-amazon-q-developer-to-jetbrains-ides) or even the [command line](https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/command-line-getting-started-installing.html). Amazon Q Developer just left Preview on April 30th and is continuously being improved based on your feedback. If something isn't working as you expect, you find a bug, or even have suggestions to improve how it works in your development flow, let me know in the comments!