Skip to content

Write ADR for method parameter guidelines #1416

Description

@danielskovli

Description

For publicly available methods, it is often convenient to pass a custom object containing the required parameters, instead of a long list of individual parameters.

This allows us to more easily avoid breaking changes to the contract, as well as allowing the callers to potentially write more compact and easily understood code.

Example

// Before
public Task<Result> Method(string org, string app, Guid id, CancellationToken cancellationToken);

// After
public Task<Result> Method(Arguments args, CancellationToken cancellationToken);

public sealed record Arguments(string Org, string App, Guid Id);

Tasks

Write an ADR containing the guidelines for the usage described above. The document should cover the following topics:

  • When is it appropriate to use custom parameter-objects vs. a list of individual parameters?
    • Is the decision here linked to the number of arguments, or should we always prefer one over the other?
  • Naming for custom types. This is probably at least partially context specific, but the guidelines should cover some common scenarios. Examples of naming:
    • [Method]Request
    • [Method]Context
    • [Method]Parameters

Metadata

Metadata

Assignees

No one assigned

    Type

    Fields

    No fields configured for Task.

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions