ConstructiCat Logo
CodeBust.
Browse section ▾

Data Clumps.

Sometimes different parts of the code contain identical groups of variables (such as parameters for connecting to a database). These clumps should be turned into their own classes.

##Signs and Symptoms

Sometimes different parts of the code contain identical groups of variables (such as parameters for connecting to a database). These clumps should be turned into their own classes.

##Reasons for the Problem

Often these data groups are due to poor program structure or "copypasta programming”.

If you want to make sure whether or not some data is a data clump, just delete one of the data values and see whether the other values still make sense. If this isn’t the case, this is a good sign that this group of variables should be combined into an object.

##Payoff

  • Improves understanding and organization of code. Operations on particular data are now gathered in a single place, instead of haphazardly throughout the code.

  • Reduces code size.