From the course: Refactoring with GitHub Copilot

Unlock this course with a free trial

Join today to access over 24,900 courses taught by industry experts.

Refactoring with Copilot

Refactoring with Copilot

If you're taking the time to refactor, it can be easy to just jump in, but taking a couple minutes to understand the code might uncover hidden things to refactor. And this is where Copilot can be super useful. This is an example of code smells. There's a processOrder() function and the createUser() function. I'm going to delete the createUser() function for this video. So the first thing I'm going to do here is ask Copilot, how would I refactor this? The output of its example is sometimes incomplete, that is, it expects you to know how to make this work. I could ask it for all the code. In this case, I think I can just copy and paste this extracted, validate order, and process order, and left to calculate total price and further processing. But shipping is gone. This is why we have to look. I'm not going to paste that. I'll leave it as it is. You get the idea. I can ask again, what else should I refactor? And this is using the context of the open file. Now this time, it identifies…

Contents