liveBook · Manning

Minimal interface

As explained in Grokking Simplicity

A stratified-design pattern in which important business concepts are represented by a small, powerful set of operations from which other operations can be constructed.

A minimal interface is a stratified-design pattern that keeps important business concepts accessible through a small, powerful set of operations. Other operations should be built from those primitives, directly or indirectly, rather than added to lower layers whenever a new feature appears. section 8.4 section 9.12

When a new function can be implemented above an existing layer, prefer that placement. This keeps lower layers focused, protects implementation details, and avoids expanding the interface that other code and teams must understand and maintain. section 9.11 section 9.12

A shopping-cart campaign

A watch discount applies when a cart exceeds $100 and contains a watch. The low-level version loops through the cart and inspects its map representation. The higher-level version combines existing operations such as calculating the total and checking whether an item is present. The second version expresses the business rule more directly without enlarging the abstraction barrier. section 9.11

Use the pattern as a design check:

  • Ask whether the new function belongs to the purpose of the lower layer or merely uses that layer. section 9.11
  • Prefer existing operations when they can express the feature clearly. section 9.12
  • Aim for a complete, minimal, durable interface, while treating that form as an ideal rather than a final destination. section 9.12
function getsWatchDiscount(cart) {
    var total  = calcTotal(cart);
    var hasWatch = isInCart("watch");
    return total > 100 && hasWatch;
}

Compare the business-level discount rule with its compact implementation using existing cart operations. section 9.11

How Grokking Simplicity covers it

How deep it goes
Explains interface growth, layer placement, and the complete-minimal-timeless ideal, stopping short of presenting it as universally attainable.
Examples
Uses a shopping-cart watch discount and JavaScript cart operations to compare low-level and higher-level implementations.
What it assumes
Assumes familiarity with stratified design, abstraction barriers, layers, and call graphs.
What you can do after
Apply it by expressing new business features through existing layer operations instead of enlarging lower-level interfaces.
How it connects
Connects minimal interface with stratified design, abstraction barriers, call graphs, straightforward implementation, and comfortable layers.

Related concepts

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