14
The Brutal Refactoring Game #CodeCopTour, Sept. 2013 Peter Kofler, ‘Code Cop’ @codecopkofler www.code-cop.org Copyright Peter Kofler, licensed under CC-BY.

The Brutal Refactoring Game (2013)

Embed Size (px)

Citation preview

Page 1: The Brutal Refactoring Game (2013)

The Brutal Refactoring

Game#CodeCopTour, Sept. 2013

Peter Kofler, ‘Code Cop’@codecopkofler

www.code-cop.org

Copyright Peter Kofler, licensed under CC-BY.

Page 2: The Brutal Refactoring Game (2013)

Peter Kofler

• Ph.D. (Appl. Math.)

• Software Developerfor 14 years

• “fanatic about code quality”

• Pair Programming #CodeCopTour

PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY

Page 3: The Brutal Refactoring Game (2013)

Workshop Structure

● Introduction 15'

● 3 Sessions a 30'

● Retrospective 15'

PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY

Page 4: The Brutal Refactoring Game (2013)

Coding Dojo Mindset

● Safe place outside work● Mistakes are ok

● We are here to learn

● Need to slow down● Focus on doing it right

PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY

Page 5: The Brutal Refactoring Game (2013)

Don't Focus on Getting it Done.F0cus on Doing

It Perfectly.

Page 6: The Brutal Refactoring Game (2013)

Code Smells

PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY

Page 7: The Brutal Refactoring Game (2013)

List of Code Smells

1. Lack of tests

2. Name not from domain

3. Name not expressing intent

4. Unnecessary if

5. Unnecessary else

6. Duplication of constant

7. Method does more than one thing

8. Primitive obsession

9. Feature envy

10. Method too long (> 6 lines)

11. Too many parameters (> 3)

12. Test – not unitary

13. Test – setup too complex

14. Test – unclear Act

15. Test - more than one assert

16. Test – no assert

17. Test – too many paths

PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY

Page 8: The Brutal Refactoring Game (2013)

Benevolent Dictator

● I want the cleanest code possible!

● Any smell must be removed immediately

● I will stop you whenever I spot a smell

● Adding functionality is forbidden until you refactor the smell away.

PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY

Page 9: The Brutal Refactoring Game (2013)

Tic-Tac-Toe

● http://en.wikipedia.org/wiki/Tic-tac-toe

● Board 3x3

● X plays first, O plays second

● Check if/who is winner

PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY

Page 10: The Brutal Refactoring Game (2013)

What Exactly Will We Do?

1. Group into pairs2. Write code (25')

● Write tests● Refactor

brutally

3. Discuss (5')● Disagreement

Cards

PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY

Page 11: The Brutal Refactoring Game (2013)

→Practice

Page 12: The Brutal Refactoring Game (2013)

Closing Circle

● What did you learn today?

● What surprised you today?

● What will you do differently in the future?

PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY

Page 13: The Brutal Refactoring Game (2013)

Peter Kofler@codecopkofler

www.code-cop.org

Game by

Adrian Bolboaca@adibolb

http://blog.adrianbolboaca.ro/2013/07/brutal-refactoring-game/

PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY

Page 14: The Brutal Refactoring Game (2013)

CC Images● Playmobil http://www.flickr.com/photos/williac/99551756/● todos http://www.flickr.com/photos/kylesteeddesign/3724074594/● Dojo http://www.flickr.com/photos/49715404@N00/3267627038/● smells http://www.flickr.com/photos/hhbw/4215183405/● question mark http://www.flickr.com/photos/oberazzi/318947873/● wants you http://www.flickr.com/photos/shutter/105497713/

PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY