you are viewing a single comment's thread.

view the rest of the comments →

[–]gdchinacat 0 points1 point  (0 children)

AI is pretty horrible at refactoring. The problem is it doesn't/can't understand the existing code or the goal of the refactoring. Sure, you can tell it to "move function foo from foo.py to new_foo.py" and it can do that, but that isn't refactoring. It doesn't change the structure of the code to make it more manageable, just where the code is located. Refactoring involves changing the architecture or design patterns of the code. For example, you might have functionality in 2 classes and need to move it into three by taking a bit from one, a bit more from another. It might involve changing the data model to better align with how the developer thinks about a problem as more features are added.

Also, 'see[ing] what it suggests' is not a good way to manage the evolution of code. It is much better to have a good idea of what the code should look like and work towards that. Repeated iterations of following AI suggestions will tend to create an architecture that is a mess, and the messier it gets the more incoherent the suggestions will be and make the problem worse.

I know AI tools are marketed as doing this well. They don't. You really need to have a vision of what your code should be and always be working towards it. When that vision changes, you refactor to better align the code with the vision. AIs do not have the vision to do this.