= Solution
Use the \b[<decorator pattern>]. The wrapper implements the same <object interface> as its component and delegates before changing the output:
``
class ScaledChannel(inner: Channel, factor: Int) extends Channel {
override def apply(n: Int): Int = factor * inner(n)
}
``
It can wrap any channel <software object>, not only a sum channel. Constructing the wrapper at run time chooses the additional behavior for an existing component, and several wrappers can be composed without adding a subclass for every combination. Each call reaches the wrapped channel once, preserving its state evolution. Scaling the input instead would define a different transformation, particularly for a component that already has history.
Back to article page