# Construct with Collaborators, Call with Work

DevFeed: [Construct with Collaborators, Call with Work](<https://devfeed.tech/articles/construct-with-collaborators-call-with-work-23870.md>)

Original publisher: [Read original article](<http://testing.googleblog.com/2026/05/construct-with-collaborators-call-with.html>)

Author: Google Testing Bloggers (noreply@blogger.com)

Published: 2026-05-05T12:28:00Z

Content type: tutorial

Language: en

Sources: [Google Testing Blog](<https://devfeed.tech/sources/google-testing-blog.md>)

Topics: [Code](<https://devfeed.tech/topics/code.md>), [business logic](<https://devfeed.tech/topics/business-logic.md>)

Tags: [business-logic](<https://devfeed.tech/tags/business-logic.md>), [code](<https://devfeed.tech/tags/code.md>), [shahar-roth](<https://devfeed.tech/tags/shahar-roth.md>), [tott](<https://devfeed.tech/tags/tott.md>)

## AI overview

A coding guideline explains that long-lived dependencies should be supplied through a constructor, while inputs that vary for each operation should be passed to methods. A ReportGenerator example separates its database and formatter collaborators from a per-call date range.

## Source excerpt

This article was adapted from a Google Tech on the Toilet (TotT) episode. You can download a printer-friendly version of this TotT episode and post it in your office. By Shahar Roth Classes require various objects and parameters to function. The "Construct with Collaborators, Call with Work" guideline can help you construct effective inputs: Use the constructor for collaborators--the dependencies that establish the object's identity. Collaborators stay with the object for its lifetime to enable it to fulfill its ongoing duties. Pass work--the parameters that change with each interaction--to methods. Unique to each call, these inputs provide the specific data needed for an operation such as a file path or database query. Consider a ReportGenerator that needs a database, a formatter, and a date range to generate a report. The database and formatter, as collaborators, are injected via the constructor, while dateRange, which varies per report generation, is passed as a method parameter to the generate method: class ReportGenerator { private final Database database; private final Formatter formatter; // database and formatter are passed as collaborators. ReportGenerator(Database database, Formatter formatter) { this.database = database; this.formatter = formatter; } // dateRange is passed as a parameter. Report generate(Range<Instant> dateRange) { return formatter.format(database.getRecords(dateRange)); } } A single ReportGenerator object can generate multiple reports with different date ranges: ReportGenerator generator = new ReportGenerator(database, formatter); Report report1 = generator.generate(dateRange1); Report report2 = generator.generate(dateRange2); Following the "Construct with Collaborators, Call with Work" guideline promotes: Reusability: Enables instances to be used for multiple, distinct operations. Testability: Separates dependency setup from business logic. Cleaner code: Hides implementation dependencies from the object's users. Predictable behavior: Locks