liveBook · Manning

Coupling

As explained in API Design Patterns

Loose coupling is a design property in which components depend on one another through limited, stable contracts and can change independently.

Loose coupling separates components through limited, stable interfaces so they can change independently. In storage APIs, retrieving data and processing resources remain distinct concerns, preserving flexibility under change. section 23.3.2 section 23.3.3

Apply the pattern by:

  • Giving input and output configurations separate interfaces. section 23.3.3
  • Modeling retrieval and export needs separately: S3 inputs use globs, while S3 destinations use prefixes. section 23.3.2
  • Reusing storage sources and destinations across multiple resource types. section 23.3.3

S3 import and export

A DataSource can describe an S3 bucket and glob such as a file-selection pattern. A separate DataDestination can describe the bucket and an exports/ prefix. Although the interfaces overlap, keeping them distinct avoids forcing import and export behavior into one contract. section 23.3.2

Listing 23.4 Example using S3 as a data destination
interface DataDestination {
  type: string;
}
 
interface S3DataDestination extends DataDestination {
  type: 's3';
  bucket: string;
  prefix: string;     #1
}

Inspect the destination interface showing how export configuration expresses an S3 prefix independently from input selection. section 23.3.2

How API Design Patterns covers it

How deep it goes
Demonstrates separate interfaces and configurations, stopping before detailed behavioral consistency rules.
Examples
Uses Amazon S3 globs and prefixes, CSV message resources, and input/output configuration interfaces.
What it assumes
Assumes familiarity with API resources, interfaces, serialized data, and external storage.
What you can do after
Apply it by designing independent storage contracts that support changing import and export behavior.
How it connects
Connects API design, separation of concerns, serialization, and external storage systems.

Also explained in

Compare how 17 books explain coupling →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of API Design Patterns. The section links point to the parts of the book it draws on.