Cohesion

From Kent Beck’s Software Design Glossary:

Cohesion fanatics, if they have to change two lines in the middle of a function, extract a helper function with just those two lines before changing them. Using this vocabulary, they are creating a cohesive sub-element before making the change instead of making the change to the larger, less cohesive parent element. This practice can seem wasteful, but it makes seeing the impact of the two-line change much easier.

I’ve found myself doing that now and again. Good to know I’m not alone.

Advertisements

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