[pro-player type="mp4"]http://j0hn.org/videos//intellij-refactoring.mp4[/pro-player]
You can see a list of some of the additional refactoring features coming in the next release of IntelliJ IDEA here. If you're a java developer, these refactoring features (and even more) are already available (yes, we're jealous).
*Notes - If you have a keen eye, you may have noticed my memory usage in IntelliJ getting pretty high while I was recording. Rest assured this was because I have 4 instances of IntelliJ running with multiple projects I was working on today on my other monitor and forgot to close them before I started recording.
If you're interested in the "art" of refactoring to clean up "code smell", I HIGHLY recommend the book "Refactoring" by Martin Fowler (that's one of the books I always keep in my "recommended books" sidebar widget)
Wow I didn't know you could move constants. with move. Nice.
ReplyDeleteOne thing to note, if you use dynamic classes, object initialisers, or uncast results of Object or '*', you need to use the preview method of 'rename' for methods/properties. The reason is easily shown through example.
Somewhere in code you have myFoo:Object = { list: "A, B, C" };
Elsewhere you have a class/property: MyClass#list
If you rename MyClass#list to, say, MyClass#things, then IntelliJ finds references to myFoo.list and renames that to "things". Can't much blame IntelliJ. MyClass is a subclass of Object.
It's not necessarily to create com package, and then example package inside com. You can just trigger Alt+Insert on src and then type com.example.bla.bla to create package hierarchy at once.
ReplyDeleteYeah, I also didn't show how it usually does a good job of warning you if a refactoring will have some sort of naming conflict to see if you want to confirm/ignore the move.
ReplyDeleteFor the "rename" refactor, how do you highlight and select all occurrences of the same variable?
ReplyDeleteUhh...wait, to select all it's Shift+Command-F7 to select all.
ReplyDelete