Extracting Data Clumps

In legacy code we often lack abstractions. How do we find these missing abstractions? Following code smells gives some ideas.

Learning Goals

Session Outline

Sort the following concepts according its relation to abstraction (i.e. grouping of related data and logic). There are four in each row, sort by highest relevancy.

Concept - Data Clump and Long Parameter List

Lecture using slides or frames about how we could find these missing abstractions? One way is to follow up on some code smells. Explain the code smells and show sample code.

Data Clump

Long Parameter List

Scan code for these code smells

Code Review: As first exercise, check out the code and look for Data Clumps and Long Parameter Lists. Allow people 5 minutes looking at the code. Then collect the group and ask what they found.

Demo

Do a 5 minute demo how to make a struct (recording or slides). Using an example of a student data clump the following steps are necessary:

Concrete Practice - Hero Quest

The Hero Quest Refactoring Kata contains some pieces of code from a RPG dealing with players and items. People work in pairs and follow the code smells to extract data clumps.

Facilitation Hints

In half an hour people can do one to two iterations, i.e. converting one to two data clumps and using them in one method each.

Conclusions - Summarise Usage

Ask the group what indications for missing abstraction could there be? How do you recognise these, when you need to introduce an abstraction?

Expected answers are

Other correct answers include