Patterns of Automated Refactoring - SoCraTesUK/socrates-uk GitHub Wiki

Patterns of Automated Refactoring

We quickly went off-topic

Rob began by demonstrating an example of a pattern for using the IntelliJ IDE tools to extract a dependency in order to make a class unit testable.

Then Rob mumbled a bit about other some other patterns and asked to see if anyone was interested in talking about what they're doing in this area. This didn't inspire much discussion, so we did mobbed on a refactoring golf exercise :)

Refactoring Golf

We used Dave Denton's refactoring golf repo (https://github.com/daviddenton/refactoring-golf).

Learned Refactorings

Type migration

This is great for inlining unnecessary generic types. To use it, over-cursor an instance of the generic type you'd like to inline and 'refactor-this', then select the refactoring you want.

Extract parameter object

This is great for creating an abstraction layer beneath a dependency injected through the constructor, or perhaps even passed as a parameter to any method (but that use case wasn't part of the golf course).

Encapsulate fields

We didn't really get this one. It seemed to generate getters and setters.

Select next occurance

This is really cool for selecting the same occurrence of some string lots of times. Often followed by an "ooooh!"

Alt-enter

A house favourite.