Extract Class Refactoring

Extract Class Refactoring

·

2 min read

Refactoring is perhaps a task that we, as developers, are doing the most. Often, we need to create a new type, whether to organize some data or extract a functionality we want to reuse.

In both cases, the usual path developers take is to open the project structure, create or find a suitable package for the new code that is about to be written, and create a new file inside.

The way I usually do it is by typing the name of the new type (class/interface) that I am about to create, and letting the IDE tell me the code doesn't exist (it won't compile)

Next, I would hit a shortcut (for me, it is Option⌥ + Enter↩) to open a panel with suggestions. The IDE itself offers me a solution for the not-compiling code

All I need to do is select the most suitable solution and press Enter again.

From an efficiency point of view, this approach saves a bunch of clicks, + it keeps my hands on the keyboard so I can proceed with the work destruction-free.

That's a tiny tip that helps me - it might be helpful for you.

Happy Coding!

p.s. I run a free community for Android Devs, and you might want to join to get a lot of valuable content, learning materials, and support. See you there!

Did you find this article valuable?

Support Jov Mit by becoming a sponsor. Any amount is appreciated!