BCS SPA2017

Red, Green, then what?

Learn how to prioritise refactorings in a smelly codebase

Workshop, 150 minutes

Abstract

The REFACTOR step in TDD is deceptively simple: you just have to improve the code, without changing what it does, right? And the experts make it look so easy: "Look", they say, "here's some duplication, which I will remove by ".

But how should you decide which duplication to remove first? What happens if you fix the "wrong" smell? And how do you even see that duplication in the first place?

In this workshop you will learn the value of Coupling as a practical tool to help plan and manage refactoring. You will explore a smelly codebase using Connascence -- an objective approach to discovering and measuring the important Coupling in an application. You won't be writing any code, but please bring a laptop so that you can download the sample code and navigate it using your preferred IDE.

Audience background

Everyone should come armed with the tools needed for exploring the code of an application. Participants should be programmers familiar with either Java, C# or Ruby.

Benefits of participating

Participants will gain introductory exposure to the use of Connascence as a tool for planning refactoring. We will explore various types of Connascence and various properties of Connascence that help in deciding "what to fix first".

Materials provided

We provide:

- a github repository containing 3 equivalent versions of a smelly application, one each written in Java, C# and Ruby
- detailed information sheets to guide the participants in their hunt for connascence in this code

Process

Participants will work in pairs or small groups to create coupling diagrams of the given codebase. Groups will share and present these to each other towards the end of the workshop.

Detailed timetable

00:00 - 00:15 Introduction
00:15 - 00:30 Divide into groups; clone the repo; ensure it builds and runs
00:30 - 00:50 Workgroups create module dependency diagrams for the codebase
00:50 - 01:00 Brief introduction to connascence (with slides)
01:00 - 01:40 Workgroups each hunt for 2 given types of connascence in the code
01:40 - 02:10 Workgroups present their findings to the room
02:10 - 02:30 Whole room discussion comparing and prioritising the connascence

Outputs

We will share coupling diagrams of the codebase with participants after the session

History

We tried this session at CodeCraftConf in September 2016. It was received well, but at 2 hours felt a little rushed. As such, we didn't have time for much discussion at the end.

Presenters

  1. Kevin Rutherford
    The XP Surgery
  2. Adrian Mowat
    Newspaper Club