DEV Community

Cover image for A practical approach to using generative AI in the SDLC
Jenna Pederson for AWS

Posted on • Originally published at community.aws

A practical approach to using generative AI in the SDLC

Have you ever taken requirements from a stakeholder, implemented them, only to have them come back to you and say "That's not what I asked for! I meant this..." It happens all the time. Sometimes we heard them wrong, sometimes we made incorrect assumptions, or maybe even the needs of the end-user changed.

You may have already seen how an AI assistant like Amazon Q Developer can help you write code and make your development more productive, and today I'd like to show you how I'm using an AI assistant to support the rest of my software development process, from idea to launch and beyond.

In the examples below, my stakeholders want to build a way for their customers to share and discover recipes and I'm using Amazon Q Developer to help me figure out what to build and how to build it. We'll step through each phase of the software development life cycle (SDLC) and this will be relevant whether you're using a traditional waterfall process or agile methodologies.

Let's get started!

Analysis, requirements, and planning

During the analysis, requirements, and planning phases of the SDLC, I'm doing a lot of information gathering, asking questions, and researching the domain. I can use Amazon Q Developer to help me with this. Using the stakeholder business idea to create a recipe sharing and discovery app, I can ask the following questions:

I'm creating a platform for users to share and discover recipes, including ingredients, steps, and images. What sort of functional and non-functional requirements should I be thinking about?

Asking Amazon Q Developer a question about analysis, requirements, and planning

Some other questions I might ask:

What questions should I be asking my customer?

What are some challenges in the recipe app domain that I need to account for?

What are some questions I should be asking you about the functional and non-functional requirements of this recipe app?

I can use these tools to better prepare me for planning meetings, ask the right questions, help think about functional and non-functional requirements, all as input into the design and architecture phase.

Design and architecture

During the design phase, I start thinking more concretely about what the architecture will look like.

I need to find accurate, up-to-date information and guidance to help me understand potential solutions, which AWS services I should use, and how to use them. Instead of spending hours reading through AWS documentation, reading through blog posts, searching on Google, before even getting started, I can explore different approaches and provide initial ideas for the design and architecture phase, evaluate pros and cons, and even get a recommendation from an AI assistant like Amazon Q Developer.

Whether you enter this phase as someone new to the tech or the domain or you're armed with knowledge and years of experience, you still have to sift through it the information, evaluate your options, and make decisions. These tools help me gain clarity by narrowing down options based on the inputs I already have (functional and non functional requirements), the trade-offs I need to think about, and help make design and architectural decisions.

In the recipe sharing app my stakeholders want me to build, I can ask questions like:

I would like to use AWS to deploy this web app. My team is made up of mostly Python engineers. We'll use Flask to build the app. What options do I have to deploy this app on AWS that include using infrastructure as code?

Asking Amazon Q Developer a question about design and architecture

Some other questions I might ask:

What are the different tradeoffs I need to think about when choosing to use Amazon ECS for this app?

Assuming we use ECS, what are the different tradeoffs I need to think about when choosing to use AWS CDK or CloudFormation for this project?

At this point, I have enough information to make a decision on how to proceed. I've decided to use Amazon ECS with Fargate to deploy this Flask app. Now I can start on the development of the app.

Development

An AI assistant also helps me with many of my development tasks. Once I know what I need to build and how to communicate that to my tools, I can start asking questions about the implementation details.

I can use it to learn how to work with libraries and APIs, explain a block of code, refactor, ask for steps on how to implement a new feature with code examples, get code completions based on existing code and comments.

Using the same example, I ask:
What are the steps to bootstrap a simple Flask app that has one route "/recipes" that outputs "My Recipes" text? I need to set up a python virtual environment and requirements.txt as part of this.

Asking Amazon Q Developer a question about development

I can generate code inline, right in my IDE, based on existing code and comments:

Inline code completion of a function using a comment as a prompt

I can also troubleshoot and debug issues, fix faulty code, or configuration. I often paste in my stack traces and ask for help:

When I run "python app.py" my Flask app does not start. There is no output when the command completes. Where should I investigate?

I'm getting this stack trace when I hit the recipes route /recipes. The app starts ok and the root route / works ok. What are some reasons I might get this error and how can I resolve it?

Hopefully, this means less forgotten print('GOT HERE') lines! Using an AI assistant to debug an issue after I've found is great, but I can also use one to prevent bad code by helping me write tests.

Testing

One of my favorite ways to use an AI assistant is to help with my tests. Often there's a recipe (pun intended!) to setting up the test suite and getting the first piece of code under test. Often this is boilerplate code, so I can use Amazon Q Developer to set up my test suite, to stub out a new test class, generate test cases based on existing code or a set of requirements via prompt, and even generate synthetic data for testing purposes.

In the recipe sharing app, I can ask questions like:

I want to create a unit test for the "/recipes" route using the unittest framework. What are the steps and example code to do that?

Asking Amazon Q Developer a question about testing

I might also ask questions about how to set up my test suite and run it, especially if this is a new-to-me code base:

I have python tests cases created in this project. Which dependencies need to be installed so that I can run these tests and how do I run the test suite?

Or to use the mocking library:

I need to mock the API call to Amazon Bedrock in the /generate-recipe route. How can I use the unittest.mock library to do this? Please provide an example.

Deployment

During the deployment phase, I can use an AI assistant to help write my infrastructure code, create deployment scripts, learn about command line deployment tools, and create images and diagrams for my docs.

For my app, I can ask:

What are the steps to deploy this Flask app as a container to ECS using Fargate?

Asking Amazon Q Developer a question about deployment

And when I'm ready to set up my CI/CD pipeline, I might start by asking for high-level steps and then drill down into each step with more specific questions:
What are the steps to set up this project's CI/CD pipeline using GitHub Actions? When a commit is made to the code repository, this action will automatically coordinate building, testing, and deploying the application to ECS for every push to the repository.

Once I've deployed the app to production and end-users are using it, I'm not done. I still need to maintain it over time.

Maintenance

During the maintenance phase, I can use an AI assistant to learn about legacy codebases, an application's architecture, or a new programming language.

I can use the Amazon Q Developer's Explain feature to get more info about a selected block of code:

Using Amazon Q Developer's Explain feature

Or even get ideas on how to optimize my AWS bill right from the AWS Console:

How can I optimize my bill this month?

Asking Amazon Q in the Console how to optimize my bill

I can transform, migrate, and upgrade a codebase or an application and I can refactor or optimize code, or even evaluate security vulnerabilities using an AI assistant.

Wrapping up

As you use a tool like this, it's important to understand how your AI assistant is trained -- on what data, for what tasks -- and then use it appropriately, using your own judgement. You may not use Amazon Q Developer in your IDE to ask about stakeholder questions, but in my situation, it worked for me. You likely wouldn't ask for unit test code examples in the AWS Console, but you would in your IDE, because that's where you are doing that work.

These are only some of the many ways you could use an AI assistant like Amazon Q Developer to help you throughout the SDLC. Whether you're using a variation of waterfall or an agile process, you can incorporate an AI assistant like Amazon Q Developer into your process. Read more about AI assistants on the Community.aws space or get started in VSCode, JetBrains IDEs, or even the command line.

How are you using AI assistants to help you with your development process? Drop a comment below to share and help others.

Top comments (0)