Wow! Refactoring with JetBrains AI Assistant
Science & Technology
Introduction
Last week, Duncan used JetBrains AI Assistant to help generate code for a package diagram. While he found the AI Assistant helpful in increasing his productivity, he was not entirely satisfied with the resulting code and suggestions for refactorings. This week, Duncan takes a different approach by manually identifying the areas of code he wants to change and asking the AI Assistant to fix them. He is impressed with the changes made and believes others will be as well.
In the previous session, the AI Assistant generated Kotlin code to generate a package diagram, but Duncan found it difficult to understand and the resulting diagram was not perfect. He also wanted to add tests to ensure the diagram would not change with future refactoring. However, the AI Assistant did not do a great job in generating the tests. Duncan decides to write the tests manually and moves on to refactoring the code.
Duncan starts by identifying areas of code he wants to change and uses the AI Assistant to make the necessary modifications. He finds the AI Assistant's suggestions, such as removing duplication and deprecations, to be helpful. However, he also notices some issues with the AI Assistant's suggestions, such as import errors and hallucinations.
Despite these challenges, Duncan continues to make changes and refactor the code. He discovers that manually modifying the code is sometimes faster and more effective than relying on the AI Assistant. However, he is still impressed with the AI Assistant's capabilities and the code it generates.
After making the necessary changes, Duncan decides to add a few final touches. He fixes some dependencies, renames files, and updates the testing and output directories. He then generates a new package diagram, which now accurately represents the code structure.
Duncan concludes by reflecting on his experience with the AI Assistant. He finds it similar to pair programming with a human, but also tiring and frustrating at times. He appreciates the AI Assistant's ability to refactor code to his preferred style, but notes that it requires micromanagement. He also mentions the need for better test runner integration and expresses his excitement for future releases of the AI Assistant.
Keywords: JetBrains AI Assistant, code generation, package diagram, code refactoring, AI Overlord, pair programming
FAQ:
- How does the JetBrains AI Assistant compare to GitHub Copilot?
- Can the AI Assistant handle multi-file code refactoring?
- Does the AI Assistant have integration with test runners?
- Can the AI Assistant generate tests effectively?
- What are the limitations of the AI Assistant in code refactoring?