Skip to content

Refactor handling of default parameters in method overloads #105

@JeremyCaney

Description

@JeremyCaney

In “Framework Design Patterns”, under 5.1 “General Member Design Guidelines”, the following recommendations should be followed:

  • DO make only the longest overload virtual (if extensibility is required). Shorter overloads should simply call through to a longer overload.
  • CONSIDER using default parameters on the longest overload of a method.
  • DO provide a simple overload, with no default parameters, for any method with two or more defaulted parameters.

This is inconsistent with how OnTopic is written, which typically relies on one method with default parameters, even in interface and virtual methods. To mitigate this, we should implement explicit, non-virtual overloads for methods with default parameters.

For interfaces, these can be implemented as default implementations so that they don’t break existing implementations, nor require support for future implementations.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions