Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
kinelski opened this issue Oct 27, 2020 · 0 comments · Fixed by #18475
Closed

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

kinelski opened this issue Oct 27, 2020 · 0 comments · Fixed by #18475
Assignees
Labels
blocking-release Blocks release Client This issue points to a problem in the data-plane of the library. Cognitive - Metrics Advisor

Comments

@kinelski
Copy link
Member

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.
@kinelski kinelski added Client This issue points to a problem in the data-plane of the library. Cognitive - Metrics Advisor labels Oct 27, 2020
@kinelski kinelski added this to the [2020] November milestone Oct 27, 2020
@kinelski kinelski added the blocking-release Blocks release label Oct 30, 2020
@kinelski kinelski self-assigned this Nov 2, 2020
@kinelski kinelski removed the blocking-release Blocks release label Nov 3, 2020
@jsquire jsquire modified the milestones: [2020] November, Backlog Nov 20, 2020
@kinelski kinelski modified the milestones: Backlog, [2021] February Jan 12, 2021
@kinelski kinelski added the blocking-release Blocks release label Jan 13, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Mar 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
blocking-release Blocks release Client This issue points to a problem in the data-plane of the library. Cognitive - Metrics Advisor
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants