[blog] Thoughts on event sourcing: Replaying events. It’s useful to be able to re-process failed messages in your event driven architecture, but there can be side effects of sending data through again.
[youtube-video] Building Projects. This is a terrific series of videos that shows off building the same sort of REST API in a variety of tech stacks. It’s a great way to get a look at different platforms like Go, JavaScript, Python. .NET, Java, and more.
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.
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.
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?
[docs] About Spanner Vertex AI integration. We just made this functionality generally available. Call ML prediction models directly from SQL statements in Cloud Spanner. It’s more performant, scalable, and usable when baked into the database process.
[blog] Friday Forward – Survivorship Bias. This is an easy bias to fall victim to. I’m sure I do all the time. Question the takeaways from “best practices” and “success stories” before mirroring them.
Today I came across some solid technical content and a handful of how-tos that you might be interested in. Take a look!
[blog] Letting our feature flags fly. Nice post from the McDonald’s Engineering team where they explain their need for feature flags in their mobile app, and their architecture for supporting it.
[article] The 5 most essential technologies for enterprises today. There’s no single list of what you should care about, as it’s contextual to your own business. But this list of items represents a reasonable set of concerns for any enterprise.
[blog] Using Google Cloud from Colab. Millions of devs use Colab to host Jupyter notebooks and experiment with Python. It’s also not too difficult to connect your notebook to Google Cloud to access a range of other services.
[blog] Generative AI Learning Path Notes — Part 1. Why take the training yourself if you can just glance at the notes of a more studious colleague? Mete published his notes for generative AI coursework, and there’s some good knowledge to pick up.
[blog] gRPC Service to Service on Cloud Run. I admittedly default to basic REST/HTTP requests when I build components that talk to each other, but really should try using gRPC more often. This post goes into some depth on setting that up.
Some good content on the interwebs today, and some spicy perspectives floating around social media. I don’t put much stock in flame-bait perspectives about “product X was a a huge mistake” or “I can never trust vendor Y”, so you’ll hopefully always see more measured takes in the content I share here each day!
[blog] Exploring WebAssembly outside the browser. Will WebAssembly ever really take off? Maybe if more use cases become mainstream, including those outside the browser.
[article] The five new foundational qualities of effective leadership. Most of these circle around the question of “how do you handle complexity?” From what I’ve observed, being effective at working in complex situations is what separates good leaders from average ones.
[blog] Estimation Isn’t for Everyone. Check out this post from the tech team at the New York Times and learn about how they think of estimating agile projects.
##
Want to get this update sent to you every day? Subscribe to my RSS feed or subscribe via email below:
I’m back after a restful vacation, and starting to wade through thousands of unread blog posts and articles in my RSS reader. Here are the handful that I consumed today.
[blog] 5 Helpful Commands for Cloud Workstations. Nate shows off a few ways to spin up and interact with cloud-based dev environments. I suspect this will be increasingly useful for those using throwaway dev environments to quickly experiment with new technologies.
[blog] What is platform engineering? Good post from Donnie that offers a practical take on platform engineering, why it matters, and how it works.
[blog] Introduction to Firebase in .NET. .NET devs can have fun too! This post walks through using the Firebase platform and Firestore databases for .NET apps.
[youtube-video] How Google Cloud reached 1 million subs. Fun video from our team that looks at the effort to earn one million subscribers to our YouTube channel.
Tomorrow I’m heading off on vacation for a full week of no news, email, chats, or work-related things. Scary! The next issue of this daily reading list will come on June 20th. Read slowly until then!
[article] Build a Strong Learning Culture on Your Team. Your team or company success won’t be dependent on adopting a particular technology or product. It’ll likely be solely based on how well—and how quickly—your team learns and adapts to things around them.
[blog] How to keep your new tool from gathering dust. How many things do you have in your house that you bought with great expectations, and then did … nothing? It happens at work too. This post has useful advice for not letting your new purchase gather dust.
##
Want to get this update sent to you every day? Subscribe to my RSS feed or subscribe via email below:
[blog] Return to the Code. Some skills come back to us after we re-engage them. Brian explains his journey to dusting off his coding skills. So much changes so quickly that even when you get back into coding, there are entirely new paradigms to learn.
[blog] Why I prefer trunk-based development. Should you work off a single main branch, or support individual branches for features, bugs, and so on? Trisha makes the case for the former in this detailed post.
##
Want to get this update sent to you every day? Subscribe to my RSS feed or subscribe via email below:
I’ve got a vacation coming up starting Friday and will go offline for a week, but there’s still too much going on to think about it much yet. Until then, here are some great reads I came across today.
[blog] Why Chatbots Are Not the Future. The chat interface helped many of us see AI as more approachable and practical. But I doubt most of us want to do all our work by chatting with a robot. There’s something better.
[blog] Local testing Spring + GCP Firestore. Emulators are good for local dev and testing. This post shows off the local Firestore database emulator that Java devs can use.
[article] AI Prompt Engineering Isn’t the Future. The point here is to get better at problem formulation versus over-investing in how to ask questions to robots.
[blog] Announcing the General Availability of Synadia Control Plane. NATS is a popular, lightweight open source product that makes it easier for distributed services to find and communicate with each other. Synadia is the sponsoring company, and has a new control plane product that looks pretty cool.
Did you have a good weekend? I was able to get some sunshine and enjoy family time. Back to work today, and I came across some very good content that you’ll enjoy.
[article] How to Take Better Breaks at Work, According to Research. Were you good about office breaks, but the work-from-home shift messed up your routine? Or are you terrific about taking a breather, regardless of where you’re working? Good article about being thoughtful about it.
[article] WordPress.com challenges Substack with launch of paid newsletters. I noticed this option last week when publishing this daily post. I can’t see ever charging folks for reading my nonsense, but it’s good to know that creators have an option on WordPress.
article] You’re Not Powerless in the Face of Imposter Syndrome. If you don’t feel some sense of imposter syndrome on a regular basis, that might be a problem. This post offers guidance to underrepresented folks, and can apply to everyone else as well.
[blog] AI-washing is taking over humanity… It takes extra effort to sift through the noise to find the signal on AI. I hope I’m helping, and not hurting!
[article] Cloud-based generative AI won’t be cheap. Relatedly, be careful about spreading around your investments. You might want to go big with those who can help you use AI to do useful things.
##
Want to get this update sent to you every day? Subscribe to my RSS feed or subscribe via email below: