Coupling

High Coupling

High probability of regressions

Essential coupling

vs

Accedental coupling

How we break things

How we break things

How we break things

Message and data coupling

type Name = {
  firstName: string,
  lastName: string,
  middleName?: string
}

const formatName = ({ firstName, lastName, middleName }: Name) =>
  [firstName, middleName, lastName].filter(val => !!val).join(" ")

// somewhere else
formatName(patient.name)

Stamp Coupling

Temporal Coupling

Control Coupling

# \EHR\PatientProfile\Projectors\PatientProjector::whenDemographicsChanged
if (self::$sideEffects && $formData) {
    $this->adtSender->send(
        $patient,
        $formData->getData(),
        $appointment
    );
}

Common and Content Coupling

Only use what you need

// overlay/src/Auth/ReauthenticationNotification.tsx

import { Timer } from "ProviderQuestionnaire/Question/DateTime"

// WAT!?

Only use what you need

Similar to ISP from SOLID

DRY

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system

Dave Thomas •  The Pragmatic Programmer