Design APIs with simple, direct interfaces rather than complex parameter passing patterns or unnecessary indirection. Use appropriate parameter types (e.g., PathFragment
instead of String
, ImmutableMap
instead of BiFunction
) and avoid expanding API surface area when existing patterns can be reused.
Key principles:
RunfilesSupport.withExecutableAndArgs()
PathFragment
) rather than generic ones (String
) for better type safetyBiFunction<ImmutableMap<String, String>, String, ImmutableMap<String, String>>
with direct parameter passingExample:
// Avoid complex function parameters
public CppModuleMapAction(
// ... other params
BiFunction<ImmutableMap<String, String>, String, ImmutableMap<String, String>> modifyExecutionInfo) {
// Prefer direct parameter passing
public CppModuleMapAction(
// ... other params
ImmutableMap<String, String> executionInfo) {
This approach makes APIs more predictable, easier to test, and reduces the cognitive load on API consumers while maintaining clear contracts between components.
Enter the URL of a public GitHub repository