The Brutal
Refactoring
Game
#CodeCopTour, Sept. 2013

Peter Kofler, ‘Code Cop’
@codecopkofler
www.code-cop.org
Copyright P...
PETER KOFLER, CODE-COP.ORG

FANATIC ABOUT CODE QUALITY

Peter Kofler
• Ph.D. (Appl. Math.)
• Software Developer
for 14 yea...
PETER KOFLER, CODE-COP.ORG

FANATIC ABOUT CODE QUALITY

Workshop Structure
●

Introduction 15'

●

3 Sessions a 30'

●

Re...
PETER KOFLER, CODE-COP.ORG

FANATIC ABOUT CODE QUALITY

Coding Dojo Mindset
Safe place outside work
●
Mistakes are ok
●

●...
Don't Focus on
Getting it Done.
F0cus on Doing
It Perfectly.
PETER KOFLER, CODE-COP.ORG

FANATIC ABOUT CODE QUALITY

Code Smells
PETER KOFLER, CODE-COP.ORG

FANATIC ABOUT CODE QUALITY

List of Code Smells
1. Lack of tests

9. Feature envy

2. Name not...
PETER KOFLER, CODE-COP.ORG

FANATIC ABOUT CODE QUALITY

Benevolent Dictator
●

I want the cleanest code possible!

●

Any ...
PETER KOFLER, CODE-COP.ORG

FANATIC ABOUT CODE QUALITY

Tic-Tac-Toe
●

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

●

Board ...
PETER KOFLER, CODE-COP.ORG

FANATIC ABOUT CODE QUALITY

What Exactly Will We Do?
1. Group into pairs
2. Write code (25')
●...
→Practice
PETER KOFLER, CODE-COP.ORG

FANATIC ABOUT CODE QUALITY

Closing Circle
●

What did you learn today?

●

What surprised you...
PETER KOFLER, CODE-COP.ORG

FANATIC ABOUT CODE QUALITY

Peter Kofler
@codecopkofler
www.code-cop.org

Game by

Adrian Bolb...
PETER KOFLER, CODE-COP.ORG

FANATIC ABOUT CODE QUALITY

CC Images
●

Playmobil http://www.flickr.com/photos/williac/995517...
Upcoming SlideShare
Loading in...5
×

The Brutal Refactoring Game (2013)

871

Published on

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
871
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
19
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

The Brutal Refactoring Game (2013)

  1. 1. The Brutal Refactoring Game #CodeCopTour, Sept. 2013 Peter Kofler, ‘Code Cop’ @codecopkofler www.code-cop.org Copyright Peter Kofler, licensed under CC-BY.
  2. 2. PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY Peter Kofler • Ph.D. (Appl. Math.) • Software Developer for 14 years • “fanatic about code quality” • Pair Programming #CodeCopTour
  3. 3. PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY Workshop Structure ● Introduction 15' ● 3 Sessions a 30' ● Retrospective 15'
  4. 4. PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY Coding Dojo Mindset Safe place outside work ● Mistakes are ok ● ● We are here to learn Need to slow down ● Focus on doing it right ●
  5. 5. Don't Focus on Getting it Done. F0cus on Doing It Perfectly.
  6. 6. PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY Code Smells
  7. 7. PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY List of Code Smells 1. Lack of tests 9. Feature envy 2. Name not from domain 10. Method too long (> 6 lines) 3. Name not expressing intent 11. Too many parameters (> 3) 4. Unnecessary if 12. Test – not unitary 5. Unnecessary else 13. Test – setup too complex 6. Duplication of constant 14. Test – unclear Act 7. Method does more than one thing 15. Test - more than one assert 8. Primitive obsession 17. Test – too many paths 16. Test – no assert
  8. 8. PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY 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.
  9. 9. PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY Tic-Tac-Toe ● http://en.wikipedia.org/wiki/Tic-tac-toe ● Board 3x3 ● X plays first, O plays second ● Check if/who is winner
  10. 10. PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY What Exactly Will We Do? 1. Group into pairs 2. Write code (25') ● ● Write tests Refactor brutally 3. Discuss (5') ● Disagreement Cards
  11. 11. →Practice
  12. 12. PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY Closing Circle ● What did you learn today? ● What surprised you today? ● What will you do differently in the future?
  13. 13. PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY Peter Kofler @codecopkofler www.code-cop.org Game by Adrian Bolboaca @adibolb http://blog.adrianbolboaca.ro/2013/07/brutal-refactoring-game/
  14. 14. PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY 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/
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×