Cover of Fundamentals of Software Architecture by Mark Richards, Neal Ford - Business and Economics Book

From "Fundamentals of Software Architecture"

Author: Mark Richards, Neal Ford
Publisher: O'Reilly Media
Year: 2020
Category: Computers

🎧 Free Preview Complete

You've listened to your free 10-minute preview.
Sign up free to continue listening to the full summary.

🎧 Listen to Summary

Free 10-min Preview
0:00
Speed:
10:00 free remaining
Chapter 3: Modularity
Key Insight 3 from this chapter

Coupling and Connascence: Metrics and Refinements

Key Insight

Coupling measures the interdependencies between code artifacts. Metrics like afferent coupling quantify incoming connections, while efferent coupling measures outgoing connections. Tools across platforms help architects analyze these characteristics for restructuring or migration. Derived metrics offer a deeper evaluation. Abstractness is the ratio of abstract artifacts (interfaces, abstract classes) to concrete ones, indicating the balance between abstraction and implementation. For an application with 5000 lines of code in a single 'main()' method, the abstractness approaches 0. Instability is the ratio of efferent coupling to the sum of efferent and afferent coupling; high instability implies a code base is prone to breakage upon change.

The Distance from the Main Sequence (D = |A + I - 1|) is a holistic metric combining abstractness (A) and instability (I), both ratios between 0 and 1. It defines an ideal relationship between these two concerns. Classes close to this idealized line are well-balanced. Classes too far into the upper-right corner enter the 'zone of uselessness' due to excessive abstraction, making them difficult to use. Conversely, classes in the lower-left corner enter the 'zone of pain' with too much implementation and insufficient abstraction, rendering them brittle and hard to maintain. These metrics assist architects in analyzing code bases for technical debt or unfamiliarity.

A concept called connascence refines coupling for object-oriented languages, stating two components are connascent if a change in one requires modifying the other to maintain system correctness. Static connascence describes source-code-level coupling: Connascence of Name (agreeing on entity names, desirable due to refactoring tools), Connascence of Type (agreeing on entity types), Connascence of Meaning or Convention (agreeing on value meanings, like hard-coded numbers), Connascence of Position (agreeing on parameter order, e.g., 'void updateSeat(String name, String seatLocation)' called with 'updateSeat('14D', 'Ford, N')'), and Connascence of Algorithm (agreeing on a specific algorithm, like security hashing). Dynamic connascence analyzes runtime coupling: Connascence of Execution (order of component execution, e.g., setting email properties), Connascence of Timing (timing dependencies like race conditions), Connascence of Values (multiple values changing together, as in distributed transactions), and Connascence of Identity (shared data structures, e.g., a distributed queue). Connascence properties—Strength (ease of refactoring, static preferred over dynamic), Locality (proximity of modules, stronger connascence is less damaging when closer), and Degree (size of impact)—guide architects and developers to minimize overall connascence by encapsulation, minimize cross-boundary connascence, and maximize intra-boundary connascence, with advice to convert strong forms to weaker ones and use weaker forms as distance increases.

📚 Continue Your Learning Journey — No Payment Required

Access the complete Fundamentals of Software Architecture summary with audio narration, key takeaways, and actionable insights from Mark Richards, Neal Ford.