Connascense
Software Engineering Topic of the Day #26
Note: This was originally written and published on the internal Armakuni Slack, by Tom Oram
Connascence is a software quality metric and a taxonomy for different types of coupling. We can use it to inform our decisions about how and where to reduce coupling in our systems.
Connascence has three properties:
- Strength
- Locality
- Degree
Each type of connascence has a different strength, lower strength ones cause less problems. Locality is whether the coupled entities are near each other (e.g. in the same class or module) or far apart (e.g. different modules, libraries or services). Degree is how many things are coupled together. These metrics should be considered together; that is, something with high strength coupling might not be bad if it is very local and has a low degree.
There are two categories of connescene types, dynamic and static. Static types can be discovered by inspecting the code, dynamic ones require knowledge of runtime. The types, in order of strength from low to high, are:
Get Billie Thompson’s stories in your inbox
Join Medium for free to get updates from this writer.
Static
- Name — things are coupled if you have to refer to the same name (e.g. function name)
- Type — things are coupled when then have to agree on the type
- Meaning — things are coupled when specific values have a special meaning (e.g. null means not found)
- Position — things are coupled when the position (in a list or set of parameters) have special meanings
- Algorithm — things are coupled when they must both understand the same algorithm (e.g. encrypt and decrypt functions)
Dynamic
- Execution Order — things are coupled when a number of actions have to called in a specific order
- Timing — things are coupled when order matter in accordance to time (think race conditions)
- Value — things are coupled when two or more values are dependent on each other
- Identity — things are coupled when a specific instance of something must be used
- Manual Task — things are coupled when manual manual coupling occurs
Connascence gives us a concrete metric to reduce the coupling in our code. When you identify the type of coupling, you can then think about how to reduce it (this is especially useful when you identify dynamic types of coupling).
For more examples, see https://connascence.io/
Q1. Which types of connascence can be caught by the compiler with statically typed languages?
Q2. Can you give an example of how to reduce from one type of connascence to another?










