ebay legacy-code-retreat

9
Refactoring by example Konrad Malawski [email protected] @ the sprinters

Upload: konrad-malawski

Post on 15-Jan-2015

3.156 views

Category:

Technology


1 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Ebay legacy-code-retreat

Refactoringby example

Konrad Malawski [email protected] @ the sprinters

Page 2: Ebay legacy-code-retreat

Refactoring to Patterns

• Internally available for free on safari: http://techbus.safaribooksonline.com/book/software-engineering-and-development/refactoring/0321213351/advance-praise-for-refactoring-to-patterns/i?query=((Refactoring+to+Patterns))#snippet

Page 3: Ebay legacy-code-retreat

Legacy Code Retreat

• We’ll use an existing codebase

• Try to understand it

• Apply automatic refactorings

• Test it

Page 4: Ebay legacy-code-retreat

Legacy Code Retreat

• github / kmalawski / legacy-code-retreat-java

• git clone [email protected]:kmalawski/legacy-code-retreat-java.git

Page 5: Ebay legacy-code-retreat

Popular refactorings• Extract Method

• Introduce Variable / Field / Constant / Parameter

• iNline

• Pull Up / Push Down

• Introduce Interface

• Move Class / Move Instance Method (F6)

Page 6: Ebay legacy-code-retreat

Popular refactorings• Rename (Shift F6)

• Extract Interface / Class

• Introduce Parameter Object

• Introduce delegate

• Introduce “null object” / Optional / Option

Page 7: Ebay legacy-code-retreat

Popular refactorings• Dependency Injection (NOT THE FRAMEWORK ”X”)

• Introduce Adapter

• Replace Conditionals with Strategy

• Remove “Primitive Obsession”

• Generify

Page 8: Ebay legacy-code-retreat

When you’re not sure

• F2 - go to next error / warning

• Meta Shift A - grep all commands

• Alt Enter - act on hints

• Ctrl T - “refactor this”

Page 9: Ebay legacy-code-retreat

Legacy Code Retreat

• 10: 25 min coding

• 20: 5 min retro

• 30: goto 10