= Solution
Use <object composition>: a logging wrapper owns a private `ResizableFrame` and delegates dimension operations to it, rather than being its subclass. The wrapper takes the before/after area around each public operation. Its own `flip` calls the component's whole `flip` once, compares only the completed states, and therefore records no increase. The component must be exclusively owned or defensively copied, so clients cannot bypass the wrapper's accounting.
\b[The component's internal calls cannot dynamically dispatch into the separate wrapper.] This prevents the setter-based `flip` implementation change from creating false log entries and reduces dependence on undocumented superclass internals. The wrapper can also choose a smaller interface. Costs include forwarding code and the loss of automatic `ResizableFrame` subtyping: code requiring that concrete superclass cannot necessarily accept the wrapper. A shared abstract frame interface can recover substitutability while keeping implementation reuse based on composition. Composition improves this dependency boundary; it does not remove the need for a clear mutation and ownership contract.
Back to article page