From the course: AI-Powered Development: GitHub Copilot in Visual Studio Code

Unlock this course with a free trial

Join today to access over 25,300 courses taught by industry experts.

Get refactoring suggestions

Get refactoring suggestions

We know we should refactor our code. That's one of the core ideas in test driven development. Once the tests are in place, we can safely improve the structure of the code as needed. So let's see if Copilot can spot any refactoring opportunities for us. Here's my query. Do you have any suggestions for refactoring the code. Again the context is this HTML file. I don't know if you saw it when it was running but it says I'm reanalyzing the code. Now that's because I have a running set of queries happening here and it's remembering what I've asked in the past. So it is revisiting refactoring ideas. The answer that it's giving me is Of course, the code is quite good for self-contained utility, but here are several suggestions for refactoring that would improve its structure, its maintainability, and security. Number one, separate concerns. We should put the HTML, the CSS, and JavaScript in separate files. So it says we should create a style CSS main.js and move all the code into the JS file…

Contents