Skip to content

[MetricsAdvisor] Consider making constructor of complex types parameterless #16321

Closed

Description

Take DataFeed as an example.

DataFeed takes multiple complex types as arguments in its constructor: DataFeedSchema, DataFeedIngestionSettings, DataFeedGranularity. Users need to know which objects are required and create them before calling the constructor:

var source = new AzureEventHubsDataSource(...);
var schema = new DataFeedSchema(new List<DataFeedMetric>() { metric1, metric2 });
var ingestionSettings = new DataFeedIngestionSettings(DateTimeOffset.UtcNow);
var granularity = new DataFeedGranularity(DataFeedGranularityType.Daily);

var dataFeed = new DataFeed("my data feed", source, granularity, schema, ingestionSettings);

Consider making the constructor parameterless. Users need to rely on thrown exceptions to figure out which properties are required:

var dataFeed = new DataFeed();

adminClient.CreateDataFeed(dataFeed); // throw: "name is required"

Next attempt:

var dataFeed = new DataFeed();
dataFeed.Name = "my data feed";

adminClient.CreateDataFeed(dataFeed); // throw: "data source is required"

We could:

  • Check that required properties are present in the client side before sending the request.
  • Let the service handle the error.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions