I don’t enjoy these 7 software development activities. Thanks to generative AI, I might not have to do them anymore.

The world is a better place now that no one pays me to write code. You’re welcome. But I still try to code on a regular basis, and there are a handful of activities I don’t particularly enjoy doing. Most of these relate to the fact that I’m not coding every day, and thus have to waste a lot of time looking up information I’ve forgotten. I’m not alone; the latest StackOverflow developer survey showed that most of us are spending 30 or more minutes a day searching online for answers.

Generative AI may solve those problems. Whether we’re talking AI-assisted development environments—think GitHub Copilot, Tabnine, Replit, or our upcoming Duet AI for Google Cloud—or chat-based solutions, we now have tools to save us from all the endless lookups for answers.

Google Bard has gotten good at coding-related activities, and I wanted to see if it could address some of my least-favorite developer activities. I won’t do anything fancy (e.g. multi-shot prompts, super sophisticated prompts) but will try and write smart prompts that give me back great results on the first try. Once I learn to write better prompts, the results will likely be even better!

#1 – Generate SQL commands

Virtually any app you build accesses a database. I’ve never been great at writing SQL commands, and end up pulling up a reference when I have to craft a JOIN or even a big INSERT statement. Stop judging me.

Here’s my prompt:

I’m a Go developer. Give me a SQL statement that inserts three records into a database named Users. There are columns for userid, username, age, and signupdate.

The result?

What if I want another SQL statement that joins the table with another and counts up the records in the related table? I was impressed that Bard could figure it out based on this subsequent prompt:

How about a join statement between that table and another table called LoginAttempts that has columns for userid, timestamp, and outcome where we want a count of loginattempts per user.

The result? A good SQL statement that seems correct to me. I love that it also gave me an example resultset to consider.

I definitely plan on using Bard for help me with SQL queries from now on.

#2 – Create entity definitions or DTOs

For anything but the simplest apps, I find myself creating classes to represent the objects used by my app. This isn’t hard work, but it’s tedious at times. I’d rather not plow through a series of getters and setters for private member variables, or setup one or more constructors. Let’s see how Bard does.

My prompt:

I’m a Java developer using Spring Boot. Give me a class that defines an object named Employees with fields for employeeid, name, title, location, and managerid.

The result is a complete object, with a “copy” button (so I can paste this right into my IDE), and even source attribution for where the model found the code.

What if I wanted a second constructor that only takes in one parameter? Because the chat is ongoing and supports back-and-forth engagement, I could simply ask “Give me the same class, but with a second constructor that only takes in the employeeid” and get:

This is a time-saver, and I can easily start with this and edit as needed.

#3 – Bootstrap my frontend pages

I like using Bootstrap for my frontend layout, but I don’t use it often enough to remember how to configure it the way I want. Bard to the rescue!

I asked Bard for an HTML page that has a basic Bootstrap style. This is where it’s useful that Bard is internet-connected. It knows the latest version of Bootstrap, whereas other generative chat tools don’t have access to the most recent info.

My prompt is:

Write an HTML page that uses the latest version of Bootstrap to center a heading that says “Feedback Form.” Then include a form with inputs for “subject” and “message” to go with a submit button.

I get back valid HTML and an explanation of what it generated.

It looked right to me, but I wanted to make sure it wasn’t just a hallucination. I took that code, pasted it into a new HTML file, and opened it up. Yup, looks right.

I may not use tools like Bard to generate an entirely complex app, but scaffolding the base of something like a web page is a big time-saver.

#4 – Create declarative definitions for things like Kubernetes deployment YAML

I have a mental block on remembering the exact structure of configuration files. Maybe I should see a doctor. I can read them fine, but I never remember how to write most of them myself. But in the meantime, I’m stoked that generative AI can make it easier to pump out Kubernetes deployment and service YAML, Dockerfiles, Terraform scripts, and most anything else.

Let’s say I want some Kubernetes YAML in my life. I provided this prompt:

Give me Kubernetes deployment and service YAML that deploys two replicas and exposes an HTTP endpoint

What I got back was a valid pile of YAML.

And I do like the results also explain a bit about what’s going. on here, including the actual command to apply these YAML files to a cluster.

Dockerfiles still intimidate me for some reason. I like the idea of describing what I need, and having Bard give me a starter Dockerfile to work with. Full disclosure, I tried getting Bard to generate a valid Dockerfile for a few of my sample GitHub repos, and I couldn’t get a good one.

But this prompt works well:

Show me a Dockerfile for a Go application that has the main Go file in a cmd folder, but also uses other folders named web and config.

The result is a Dockerfile, and it’s well explained in the accompanying text.

Bard also seems pretty good at giving me Terraform, Java property file configurations, and more. As always, verify the results!

#5 – Create sample data

I build a lot of sample apps, which means I need sample data. That might mean input into a REST endpoint, or it could be data for a starter database. Instead of struggling to produce a bunch of fake records, generative AI solutions can give me all the structured data I need.

In the SQL section above, I generated a SQL insert command that I could use for a database. But I can also generate some seed data for my app.

For instance, how about this prompt:

Generate a JavaScript variable holding a JSON array of five baseball players. Pull names from the baseball Hall of Fame. Each record should have an id, name, position, and age.

I get back valid JSON that I could drop in my Node.js app.

I can then ask Bard to convert that to XML, CSV, or any number of formats. I might want more records or fewer records. This also works if you ask for your favorite television characters, musicians from the 1990s, or types of potatoes. Generate data without taxing your brain.

#6 – Explain code I come across in GitHub, blog posts, or StackOverflow

Do you ever find some interesting code in a blog post or StackOverflow answer but can’t exactly figure out how it works? Happens to me all the time. Instead of going further down the rabbit hole to figure out what each line of code does, I can use generative AI to make some sense of it all.

For instance, let’s assume I’m terrible at generating random numbers and stumble upon this StackOverflow answer that’s succinct and without any description. I can ask Bard to describe this code in more depth:

What does this code do? Explain it to me as if I’m new to C#. public string RandomDigits(int length)
{
var random = new Random();
string s = string.Empty;
for (int i = 0; i < length; i++)
s = String.Concat(s, random.Next(10).ToString());
return s;
}

What I get back is a written description of each line. And then, helpfully, a restating of the code with comments added before each statement.

If you’re learning a new language, consider using generative AI to explain code snippets to you. I acknowledge that I’ve had mixed luck pointing Bard at a code file or repo and getting a perfect explanation. I sometimes get hallucinations (e.g. refer to files to methods that don’t exist), but I expect this functionality to get better quickly.

#7 – Convert code from one language (or version) to another

Do you ever come across code that shows a useful pattern, but isn’t in the language you’re coding in? Maybe I found that code above to generate a random number, but want the equivalent in Go. Not a big problem any more. A prompt following the above prompt:

Convert this C# code to Go code instead

I get back Go code, and a description of what’s different.

Consider the case where you find code for calling a particular HTTP endpoint, but it’s in Java and your app is written in Go. My colleague Guillaume just wrote up a great post about calling our new Google PaLM LLM API via a Java app. I can ask for all the code in the post to be converted to Go.

The prompt:

Can you give me the equivalent Go code for the Java code in this blog post?/ https://glaforge.dev/posts/2023/05/30/getting-started-with-the-palm-api-in-the-java-ecosystem/

That’s pretty cool. I wasn’t sure that was going to work.

With all of these examples, it’s still important to verify the results. Generative AI doesn’t absolve you of responsibility as a developer; but it can give you a tremendous head start and save you from wasting tons of time navigating from source to source for answers.

Any other development activities that you’d like generative AI to assist you with?

Comments

5 responses to “I don’t enjoy these 7 software development activities. Thanks to generative AI, I might not have to do them anymore.”

  1. […] I don’t enjoy these 7 software development activities. Thanks to generative AI, I might not have t…. From me, today. I wrote up my experiences offloading un-exciting tasks to […]

  2. […] I don’t enjoy these 7 software development activities. Thanks to generative AI, I might not have t… (Richard Seroter) […]

  3. July 3, 2023 Weekly Update on Microsoft Integration Platform & Azure iPaaS - Hooking Stuff Together Avatar

    […] I don’t enjoy these 7 software development activities. Thanks to generative AI, I might not have t… by Seroter  […]

  4. […] has been written—some by me—about how generative AI and large language models help developers. While that’s true, there […]

  5. […] I don’t enjoy these 7 software development activities. Thanks to generative AI, I might not have t… There’s a lot of toil in software development, and generative AI may eliminate a lot of it. […]

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.