Leveraging Generative AI for Efficient Code Refactoring and Enhanced Documentation

I've been working on a project for the last few months, transitioning it from research to software development. Leveraging generative AI has significantly helped in this process. As a competent programmer and architect, this approach has allowed me to concentrate on the architecture while utilizing techniques like generative AI-enhanced Test-Driven Development (TDD).

During this time, I experimented with various generative AI software development tools. Without delving into specifics, one key benefit stood out. Once I had an algorithm that was logically correct, I would prove its functionality using TDD. Efficiency wasn't my initial focus; I just wanted a working solution.

Next, I used generative AI to "simplify and make the code more readable". This process involved highlighting the code and asking the AI to enhance its clarity. I found that the AI often devised a better algorithmic approach, making the solution not only more efficient but also easier to understand.

The use of generative AI in refactoring existing code has proven to be a powerful approach. I plan to continue exploring this method as I move forward. The clarity and simplicity it brought to my code were remarkable. This ease of understanding even extended to documentation. Normally, I believe that excessive documentation can be misleading and that clean code should speak for itself. However, the ability to quickly generate meaningful comments by simply instructing the AI to "comment this block" has been a game changer. It makes the code more accessible to newcomers without introducing confusion.

I found it efficient to take a day at the end of the development process to thoroughly document the code, ensuring that all exception handling, especially in C#, was well-covered. This approach significantly improved the quality of the code compared to what I could have achieved without the aid of generative AI. Additionally, as a polyglot programmer, it's challenging to stay current with the latest features and improvements across different languages. Generative AI has been invaluable in this regard, serving as a continuous learning aid and helping me stay updated with new language developments.

The ability to speak to generative AI and have it reinterpret my words is another powerful tool, significantly faster than typing. A few hotkeys to activate the audio prompt in VS Code, followed by verbal instructions to the AI, has streamlined my workflow even further.

Additionally, using canned prompts as snippets has been highly effective. Often, a well-crafted prompt or comment above a piece of code guides the generative AI in completing the code efficiently. By integrating standardized or saved prompts into my snippet list, I can quickly execute common tasks, enhancing both speed and consistency in my coding process.

The big strength that humans bring to the table is pure creativity in solving problems, a domain where AI still lags behind. Another significant aspect is scoping. Every software developer knows that we don't tackle the entire problem domain or final solution all at once.

In summary, the combination of generative AI for refactoring, documentation, continuous learning, and now voice commands and standardized prompts, has elevated the quality and efficiency of my software development efforts.

You said you are a "competent programmer and architect". You are an exceptional programmer and architect, one of the best I have ever worked with. Hope things are great.

To view or add a comment, sign in

More articles by Mark Grandau

  • Why is Diversity all about Trust?

    Trust, as you might notice from my previous posts, is an interest of mine. Two distinct channels of trust are in play…

  • VSCode: Good for CleanCode

    A foundation belief in CleanCode is that: "Code is not written to solve the problem. It is written to tell the story of…

  • The Trick to Winning: Trust

    In continuous improvement methodologies, we are trained to do root cause analysis. But yet when it comes to judging…

    2 Comments
  • Doing vs Being

    For anyone wanting to make fundamental root changes to something, you need to know the difference. It is what allows…

    1 Comment
  • Use-case Approach to Bookmarks in Your Browser

    If you're like me you have accumulated lots of bookmarks over the years. Switching browsers and OSes on multiple…

  • The Trust side of Small Group Dynamics

    We have all seen the "Forming, Storming, Norming and Performing" cycle for small groups. It's been around since the…

    2 Comments
  • The CAP Theorem should be CAP Law of Software Architecture

    I’ve been doing software for nearly 30 years now. Nearly 28 of them doing distributed systems.

    3 Comments
  • Interest-based Problem Solving

    Interest-based problem solving Nice article on trust-centric management approach.

  • Mindmaps, Mohiomap and Evernote

    So I've used all these. Mindmaps are my ace up my sleeve at work.

    1 Comment
  • Event Driven Architecture (EDA) over Enterprise Service Bus (ESB)

    http://www.ibm.

    1 Comment

Others also viewed

Explore content categories