Composing Objects with Separate Roles

Object composition supplies one object with collaborators handling responsibilities that can be described independently.

Source
Anbloq
Language
English
Created
Updated
Chapters
2
Reading time
1 min
In this article2 chapters
  1. Trace a report service
  2. Check the boundary between roles

Trace a report service

A report service can receive a reader for source rows and a formatter for the output representation. Runtime selection can choose a CSV or JSON formatter without changing the report's calculation. Dependency arguments are the corresponding function-level technique.

Check the boundary between roles

If the formatter needs decoded values and receives raw bytes, each collaborator can individually work and the composition still fail. A boundary integration test should use an actual result from the reader.[1]

References

  1. Python Software Foundation, Python Tutorial: Classes ↩