From the course: Refactoring with GitHub Copilot

Unlock this course with a free trial

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

Refactoring strategies

Refactoring strategies

Before I dive into using Copilot to aid in refactoring, I want to high-level some ways to think about refactoring. One of my favorite sites on the internet is refactoring.guru. They have a catalog of refactoring techniques. Looking at the first one here, composing methods, you can see they define this as correctly composing logic. The first strategy is to extract methods, followed by the next strategy for inlining methods. Extracting a method in TypeScript shows taking a small piece of logic and creating a new function with it. So the print details function is new. Jumping to the inverse, take a small method called once and move it inline. At first, it seems like these are opposites, but the factor that makes them different is what is driving the need. Now, I'm not going to jump through all of these, but know that this resource exists. Scrolling down, there's moving features between objects. The next portion is about organizing data, and it hits one of my biggest flags in PHP. If…

Contents