Symptoms
CausesSomeone needs a value, so they put it in the code. On its own, perhaps it's not so bad, but often there are other values derived from or dependent on it. For example, we'll have a string defined banana and a length variable of 6. If you change the string, you need to change the length variable; however, this is not obvious, and so a defect gets in. This is often a simple form of duplication, and it's especially easy to spot. What to Do
PayoffReduces duplication. Improves communication. ContraindicationsTests are often more readable when they simply use the value they want, but even in that case you might pull out a symbolic constant when there are derived values involved. If you've moved to a map solution, the keys must be coordinated between the code and the map. |