---
title: "Higher-Order Code Smells (Part 2)"
source: "/writing/higher-order-code-smells-part-2/"
---

Article

# Higher-Order Code Smells (Part 2)

Collin Flynn

August 21, 2021

[Aaron Burden via Unsplash](https://unsplash.com/@aaronburden)

In [Part 1](/writing/higher-order-code-smells) 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](/writing/higher-order-code-smells) 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.

Maybe we should go this way?

If a well-lit stroll on pre-determined path is how you designed the application, then a [_Desire Path_](https://en.wikipedia.org/wiki/Desire_path) is when you violate your own rules and trample the grass.

You could've made a path, but you didn't.

At least pedestrians have an excuse. You pave your own roads.

## 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 Kotlin`Flow`). Downstream application components can watch and react appropriately when preferences change.

Additionally, suppose the `PreferencesRepository` has some method to set the UI theme, perhaps `DARK_MODE`. Below we see the `setUiTheme(theme)`method:

See any strange?

And since the application has to restart after a `Theme` change, it just... _hey wait a second!_

`Application.restart()`?

This is a contained example of an architecture pattern right next to its violation -- the observable has become the observer. Responsibilities out the window! In a sample this small, the fix is clear: let some other component observe the `StateFlow` for theme changes and react with its own restart logic. But in a large application, this kind of pattern violation can induce havoc during a difficult refactor, or upgrading dependencies, or trying to isolate coupled components. That's why it's so important to not introduce a _Lateral Pass_ as a hack (see: [shortcut vs hack](/writing/take-more-shortcuts) , because the difference matters).

Sometimes a developer will write a _Lateral Pass_ if they're failing to embody the perspective of the application component they're writing. The developer _just knows_ what should happen next, not considering what the component itself should know.

That's all for now!

_Collin keeps the grass green at_ [_Livefront_](https://www.livefront.com) _._

-   Collin Flynn

    Principal Software Engineer

    Collin Flynn

### Tags

[Digital Engineering](/insights/all/?topic=digital-engineering)

### Share

-   Copied

## View these next.

[See all](/insights/all/?type=writing)

-   [

    Article

    How To Sabotage Your Project Using Inconsistency

    Collin Flynn

    ](/writing/how-to-sabotage-your-project-using-inconsistency/)
-   [

    Article

    Unit Testing race conditions by creating chaos (Swift)

    Sean Berry

    ](/writing/unit-testing-race-conditions-by-creating-chaos-swift/)
-   [

    Article

    UIApplicationDelegate call sequence reference

    Sean Berry

    ](/writing/uiapplicationdelegate-call-sequence-reference/)
