Article
Higher-Order Code Smells (Part 2)
August 21, 2021
In Part 1 we established the idea of the higher-order code smell: how small units of disorder combine to make surprising new problems (and complex odors). Little deferrals of (extra) effort aggregate into more trouble than the sum of their weights. Check it out here to see the first example, the N-dimensional Object — a monster of too many purposes.
Here in Part 2 we’re looking at another — and this one likes to hide until you’re making large, difficult changes. The very moment you least want surprises.
Start by visualizing your application architecture as a set of walkways, sending traffic on designated paths to their architecture-sanctioned destinations.

If a well-lit stroll on pre-determined path is how you designed the application, then a Desire Path is when you violate your own rules and trample the grass.
You could’ve made a path, but you didn’t.

The Lateral Pass (Aka the Path of Desire)
A surprising back-channel pass of information in violation of existing architecture, which couples components that have no reason to know about each other.
Characterized By, (1) Inappropriate Intimacy, (2) God Object, and (3) Uncontrolled Side Effects
A lateral pass is an undisciplined call or data handoff that some too-clever component “just knows” to make.
It’s often an over-share of information exposing implementation details across application layers (1). To perform it, an object has to overstep its boundaries (2) and the links between these layers can get accidentally broken during refactoring due to an obfuscated connection outside of the architecture (3).
An example.
Here’s a repository
that holds the user’s Preferences
, and exposes changes to those preferences as an observable
value (in this case, a KotlinFlow
). Downstream application components can watch and react appropriately when preferences change.