Adapter pattern (source code)

= Adapter pattern

An adapter presents an <object interface> expected by clients while delegating to a component with a different <object interface>. Correct adaptation preserves the meaning and order of operations, not merely <object method> names. Adapting a combined update-and-result operation to separate update and query operations requires storing the last result and specifying its initial value. An adapter should not perform a hidden dummy update just to manufacture that initial observation.