Keyboard Shortcuts: Refactoring - Part 3

Keyboard Shortcuts: Refactoring - Part 3

In today’s episode, we’re adding two more powerful refactoring shortcuts to our IntelliJ IDEA toolkit — *Extract Parameter* and **Inline Method**. 🔧 *Extract Parameter* First up — **Extract Parameter**. This one belongs to the “extract stuff” family. You’ve used *Extract Variable**, maybe **Extract Method* — now meet their useful cousin. So when do you use it? Let’s say you’re using a field or a hardcoded value inside a method, and you want to pass it in as a parameter instead. This shortcut handles it beautifully. 🖱️ Just place your cursor on the expression, then hit: **Mac**: `Cmd + Option + P` **Windows**: `Ctrl + Alt + P` IntelliJ gives you a prompt to name the new parameter — and boom! It updates the method and all its call sites. 💡 So if your method is being used in 10 different places? IntelliJ updates all 10 of them for you. No manual fixes needed. Let me show you — Here I want to extract this part as a parameter. I hit the shortcut, name it, and that’s it. The method signature changes, and all the callers are updated automatically. So smooth. --- 🔄 *Inline Method* Now for the opposite move — **Inline Method**. Ever written a method so short that it barely needs to exist? One line, maybe even less? That’s your cue to inline it. Here’s what it does: Instead of calling the method, IntelliJ replaces the call with the method’s body — right where it’s used. 🖱️ The shortcut is: **Mac**: `Cmd + Option + N` **Windows**: `Ctrl + Alt + N` Let’s try it out. I have this one-line method — I hit the shortcut, and IDEA replaces the method call with its contents. Clean and concise. Perfect for when you want to simplify your code and reduce unnecessary indirection. --- 💬 *Wrap-up* These refactoring shortcuts are intuitive, powerful, and honestly — just fun to use. They make your coding flow smoother and your code cleaner — all without lifting your hands off the keyboard. Try them out, and let me know which refactoring shortcut is your favorite so far! Until next time — keep coding, keep crafting! 👨‍💻⚡