Best fit
Sequential processing pipelines, ingest flows, message enrichment, and staged transformations.
Not every system is best understood as controllers, services, and repositories. Some problems are processing pipelines: validate, enrich, transform, score, route, and emit. Pipes and Filters is a better mental model for those cases.
Batch imports, fraud screening, pricing pipelines, event enrichment, and document processing often work better as composable stages than as one large service with many conditional branches.
Pipes and Filters treats the system as a chain of processing stages. Each filter performs one focused transformation, validation, or enrichment. The pipe carries the result to the next stage. This often leads to better composability and clearer operational reasoning for streaming or staged processing problems.
The style is less suitable when the primary difficulty is rich business modeling around stable aggregates. It works best when the dominant structure is flow and transformation.
Sequential processing pipelines, ingest flows, message enrichment, and staged transformations.
Each step can stay small, testable, and replaceable.
Once the pipeline needs too much shared mutable context, the style starts to fray.
package org.javaomnibus.ecommerce.pipeline;
public interface Filter<T> {
T apply(T input);
}
public final class ValidateOrderFilter implements Filter<OrderImportRecord> {
@Override
public OrderImportRecord apply(OrderImportRecord input) {
if (input.lines().isEmpty()) {
throw new IllegalArgumentException("Order must contain at least one line");
}
return input;
}
}
public final class FraudScoreFilter implements Filter<OrderImportRecord> {
@Override
public OrderImportRecord apply(OrderImportRecord input) {
return input.withFraudScore(42);
}
}