Duplication is far cheaper than the wrong abstraction

Sandy Metz said that if you find yourself passing parameters and adding conditional paths through shared code, the abstraction is incorrect. Then you should go back:

  1. Re-introduce duplication by inlining the abstracted code back into every caller.
  2. Within each caller, examine the parameters that got passed in order figure out which bits of the inlined code you actually use.
  3. Delete the bits that aren’t needed for this particular caller.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s