CSE Roadmap

Common tier · about 3 hours · 7 parts

Part 5 of 7 · 3 min read

Connascence

Two parts are connascent when changing one forces a change in the other.

Think of a recipe with a shopping list. If the recipe says "2 onions" and the list says "onions: 2", a change to one means changing the other. That is a tie. A tie that is easy to see and fix, such as a shared name, is mild. A tie that hides, such as "the third number is always the price", is dangerous.

Meilir Page-Jones (1996) defined connascence (from a Latin word for "being born together"): two components are connascent if a change in one would require the other to be modified to keep the system correct. FSA presents two families.

Connascence

Connascence is a relationship between two parts of a system in which a change to one forces a change to the other for the system to stay correct.

Example: a client and a server must both use the same hash algorithm. If one changes it, login fails.

Static connascence can be found by reading the source code:

Kind Parts must agree on Example
Name The name of something A method name used by callers
Type The type of something A parameter typed as a number
Meaning (convention) What a value means status = 3 means "paid"
Position The order of values book(seat, name) called as book(name, seat)
Algorithm The same method of computing A hash used by client and server

Dynamic connascence shows up only at run time:

Kind Meaning Example
Execution Order of execution matters Setting a subject after sending the mail
Timing Timing matters A race between two threads
Values Several values must change together Updating one value in each of three databases, all or none
Identity Parts must refer to the same entity Two services sharing one queue

Dynamic forms are harder to find, because tools can analyse source code better than run-time calls. FSA notes that connascence of values appears in distributed transactions, which Level 5 covered.

Three properties help decide what to fix first:

  • Strength: how hard it is to refactor. Name is the weakest, which is the easiest to fix, since tools can rename across a code base. Prefer static to dynamic. A magic number (meaning) can be turned into a named constant, so meaning becomes name.
  • Locality: how close the parts are. Strong ties inside one module cause less harm than the same ties between modules.
  • Degree: how many parts are affected. A small degree today may become large as the code grows.

Jim Weirich's two rules, quoted in the book: the rule of degree says to turn strong forms into weaker ones, and the rule of locality says to use weaker forms as the distance between elements grows.

A worked example (made up). A service returns order status as the number 1, 2 or 3. Fifteen other services read it.

Step Connascence Strength Degree
Today Meaning (what does 3 mean?) Medium 15 services
After using named values PAID, SHIPPED Name Weak 15 services

The change costs a little code, and a future change to the meaning of a value can now be found by searching for the name.

FSA ends with two limits of connascence for modern architects. It looks at low-level details of code quality, but architects care more about how modules are coupled, such as synchronous or asynchronous communication. And it does not address that choice for distributed systems like microservices. Pages 5 to 9 of this level take that up.

Read it as

Make ties visible (name), keep strong ties close (same module) and keep far-apart ties weak.

Check yourself:

  • Is a function called calc(price, tax) but called as calc(tax, price) a name, type or position problem?
  • Why should a strong tie be kept inside one module?