Become a Pragmatic and Productive Software Developer with AI

“At your service, sir.” - J.A.R.V.I.S. in Iron Man

I posted a video on my social media about my programming activities a week ago. Someone asked for my opinion about GitHub Copilot and whether it is a good idea to use it. I found that question fascinating. After reading that question, I started thinking about the role of Artificial Intelligence in this technology era. My answer was that a software developer, with the help of AI, can form an excellent team as long as we can utilize AI to make us more pragmatic and productive as developers. I also told him that I use ChatGPT to assist me in my professional career. To be honest, I really like it and feel more productive with the help of ChatGPT (AI).

In the near future, I believe AI will be more widely implemented in many aspects of our lives. AI is coming, and it’s inevitable. As software developers, let us use this technology as leverage to become more productive and pragmatic.

Pragmatic & Productive

Let’s take a look at the meaning of a pragmatic and productive software developer. This is an explanation about pragmatic and productive software developers from ChatGPT. A pragmatic and productive software developer is someone who approaches software development with a focus on practical solutions and efficiency. They balance idealistic technical goals with real-world constraints. Thus, it’s not just about technical skills but also about a mindset and practices that lead to effective and efficient development outcomes. They aim to deliver value quickly while maintaining high standards of quality and adaptability.

Pretty straightforward, right?

AI as your teammate

To unleash the power of AI, let’s make AI our teammate. I believe adopting this mindset is a great starting point to more effectively utilize AI technology. Currently, you have a teammate that won’t judge your questions, no matter how dumb and stupid they may seem, and might even provide you with strategic insights or ideas to achieve your goals. However, you need to define your goals clearly and refine your skills accordingly. You can’t achieve your goals by delegating everything to AI. It can make mistakes and sometimes be incorrect. The more you refine your skills and collaborate with AI, the more accurate your steps will become in getting closer to your goal.

Now, let me give you examples of my approach to collaborating as a team with AI (ChatGPT) to enhance the software development process.

For example, I want to enhance my C# code that handles JSON company information. Here is my code.

using JsonSerializer = System.Text.Json.JsonSerializer;

namespace JsonHandlers
{
    public class CompanyInfo(string name, string address)
    {
        public string Name { get; set; } = name;
        public string Address { get; set; } = address;
    }
    
    internal class Program
    {
        private static async Task Main()
        {
            var companyInfo = await JsonFileReader.ReadAsync<CompanyInfo>(@".\companyInfo.json");
            Console.WriteLine(companyInfo?.Name);
        }
    }

    public static class JsonFileReader
    {
        public static async Task<T?> ReadAsync<T>(string filePath)
        {
            await using var stream = File.OpenRead(filePath);
            return await JsonSerializer.DeserializeAsync<T>(stream);
        }
    }
}

I copied and pasted the above code into ChatGPT, and it generated a new structure for better performance, readability, and maintainability.

using System;
using System.IO;
using System.Text.Json;
using System.Threading.Tasks;

namespace JsonHandlers
{
    public class CompanyInfo
    {
        public string Name { get; }
        public string Address { get; }

        public CompanyInfo(string name, string address)
        {
            Name = name;
            Address = address;
        }
    }

    internal class Program
    {
        private static async Task Main(string[] args)
        {
            try
            {
                var companyInfo = await JsonFileReader.ReadAsync<CompanyInfo>(@".\companyInfo.json");
                Console.WriteLine(companyInfo?.Name);
            }
            catch (FileNotFoundException)
            {
                Console.WriteLine("Error: File not found.");
            }
            catch (JsonException)
            {
                Console.WriteLine("Error: File contents could not be parsed.");
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Unexpected error: {ex.Message}");
            }
        }
    }

    public static class JsonFileReader
    {
        public static async Task<T?> ReadAsync<T>(string filePath) where T : class
        {
            await using var stream = File.OpenRead(filePath);
            return await JsonSerializer.DeserializeAsync<T>(stream);
        }
    }
}

Now, my code has better error handling which is helpful for maintenance and debugging.

The second example is that I want to create an authentication process using a DLL library in my C# code. I discussed this with my teammate (AI), mentioning that I have Authenticator.dll and want to call the AUTH_Open method inside this DLL. This method takes one parameter: a string named workingDirectory.

Then, ChatGPT generate this code.

using System;
using System.Runtime.InteropServices;
using System.Text;

class Authenticator
{
    private const string DllName = "Authenticator.dll";

    // Define the P/Invoke signature for AUTH_Open
    [DllImport(DllName, CharSet = CharSet.Auto, CallingConvention = CallingConvention.Cdecl)]
    private static extern bool AUTH_Open(string workingDirectory);

    // Other function definitions can be added here...

    // Method to call AUTH_Open
    public static bool OpenAuthenticator(string directory)
    {
        return AUTH_Open(directory);
    }
}

It’s working, and I’ve made a good start on my code.

Wrap-up

You can work alongside your teammate (AI) to tackle challenges in your software development process. Whether it’s refactoring, making things better, or debugging, AI’s got your back. This way, you get to up your game at work and keep growing as a pragmatic and productive software developer. Plus, you’ve got a coding partner to share the load.

Let’s code with joy, with AI!