Think Like a Programmer in the AI Age

Think Like a Programmer in the AI Age

By: Aaron Ploetz

(Author, Think Like a Programmer)

In this post, I will introduce my new book, Think Like a Programmer - Practical Java Solutions for Students, Developers, and Interview Preparation. In this book, I take a look at different Java programming problems and walk the reader through addressing these problems in a consistent, structured approach. Here we will also discuss this approach in the context where more code is being written by AI agents and how to apply it in today’s world.

The idea behind the Think Like a Programmer book was to build a resource of programming problems that could be referenced by someone just learning Java, someone refreshing their skills, or someone preparing for a technical interview. Each problem would be presented to the reader, followed by a discussion of the algorithm or approach, a flowchart, the Java code to solve the problem, and finally an explanation of what the code is doing. Breaking down each potential problem like this allows for a resolution to be pursued in a logical and methodical way.

Example Problem

Let’s start with an example.

Problem: Reverse a String

Take a string as input and return it with its characters in reverse order.

Steps to solve:

  1. Create a new method named reverseString, which accepts a String variable named inputStr. This method should also use String as its return type.
  2. Instantiate a new object named reversed of the StringBuilder class.
  3. Create a for loop with a counter named arrayIndex. Initialize arrayIndex to the length of inputStr, and decrement it by one on each iteration of the loop.
  4. Use the charAt() String method to access the current character denoted by arrayIndex. Append this character to the reversed StringBuilder object.
  5. Once the loop has completed, call the toString() method on the reversed object and return that value to the calling program.

Flowchart:

Figure 1: Flowchart describing how to reverse a string.

Java Code:

As with all programming problems, there are many ways in which it could be solved. For this problem, we will use the following Java code:

private static String reverseString(String inputStr) {

    StringBuilder reversed = new StringBuilder();

    for (int arrayIndex = inputStr.length(); arrayIndex > 0; arrayIndex--) {
        reversed.append(inputStr.charAt(arrayIndex - 1));
    }

    return reversed.toString();
}
    

Code explanation:

To solve this problem, we will create a new method named reverseString, which accepts a String parameter named inputStr and also returns a String value. Inside the method, we instantiate a new StringBuilder object named reversed. We then use a for loop to iterate through each of the characters in inputStr, but starting from the last character in the string.

Inside the loop, we take the string at arrayIndex - 1 and append() it to reversed. Once we have made it to the first character of inputStr, the loop ends and we return the String value of reversed back to the calling program.

Relevance to Agentic Software Development

How is this relevant in the world of agentic AI coding agents? It’s relevant because the code isn’t the important part. Programming and software development have always been about problem solving. In the AI age, that is still true. The only thing that changes is the toolset.

There are many Agentic coding tools available, including Cursor, Claude Code, and IBM Bob. So how would we solve this with an agentic coding tool? We would have to give it a proper prompt. Agentic coding tools use a chat interface, which accepts a prompt from the user. With the description given in the prompt, it then attempts to interpret a solution.

For our problem, we can try a prompt like this:

Can you help me write a method in Java to reverse a String? The method must accept a String parameter for input, reverse that String, and then return that reversed value.

My coding agent then produces this code:

public String reverseString(String input) {
    if (input == null) {
        return null;
    }
    return new StringBuilder(input).reverse().toString();
}
    

Similarly, the agent-produced code also makes use of the StringBuilder class. But it takes an even simpler approach and calls StringBuilder’s reverse() method. The agent also checked for null, which is a good reminder for us (myself included) to validate our inputs.

The important thing to understand is that while our agent produced the code, the role we play in articulating the problem to the agent is still important. We didn’t just “vibe code” it by saying “reverse a word”; we gave it clues as to how to solve the problem. We used keywords like “method” and “accept.” We gave it an opinionated stance on which technology (Java) should be used. We even gave it a specific data type of “String” to use for both input and output. These key points are what influenced the agent to return a concise, working solution.

Conclusions

In this post, we have discussed my new book Think Like a Programmer - Practical Java Solutions for Students, Developers, and Interview Preparation, and its role in helping software developers to learn how to approach programming problems. We also looked at how this approach remains relevant, even as the AI-driven tools of the future take shape.

Some tech industry pundits will say that no one will need software developers anymore. I disagree and say that this is similar to how, 40 years ago, so much code was written in Assembly Language. As the recent decades progressed, fewer developers wrote code in Assembly anymore, instead choosing to use third-generation languages like Java, C++, and Python. Does that mean that understanding Assembly isn’t relevant anymore? Of course not. It’s just that newer languages (tools) made it easier to build software faster than you could with Assembly.

That’s where we are today. The tools are changing, but the understanding required to solve programming problems isn’t. Remember - The code was never the important part.

Next Steps

If you haven’t done so already, go ahead and download an Agentic coding IDE (Integrated Development Environment). There are several available options, and most have a free tier that you can get started with:

And of course, be sure to check out my new book Think Like a Programmer - Practical Java solutions for students, developers, and interview preparation.

Back to blog