Skip to content

Heavy cleanup/abstractions#29

Merged
SeppPenner merged 2 commits intoSeppPenner:masterfrom
Patrick2607:master
Oct 18, 2022
Merged

Heavy cleanup/abstractions#29
SeppPenner merged 2 commits intoSeppPenner:masterfrom
Patrick2607:master

Conversation

@Patrick2607
Copy link
Copy Markdown
Contributor

@Patrick2607 Patrick2607 commented Oct 11, 2022

This commit heavily refactored the value classes. Please check the attached 'ValueClasses.cd' in the SparkplugNet Project or view the Class Diagram directly.

  • Heavily cleaned/refactored PayloadConverter (number of lines reduced by almost 60%)

  • Removed MetricBase

  • Added ValueBase class as base for all shared data classes

  • Added ValueBase class children for Sparkplug Version A and B

  • Added DataTypeExtensions class for converting data types (decoupled it from MetricBase)

  • Removed Value property from IMetric (IValue takes care of this now)

  • Added interface IValue for value classes

Changed some names for consistency in Value types for A and B:

  • Renamed 'Bool' to 'Boolean'

  • Renamed 'Integer' to 'Int'

  • Renamed 'Type' to 'DataType'

  • Added/Renamed ValueCase (uint) and DataType (Enum) as properties for IValue (used this renaming for consistency purposes. Some classes used ValueCase as Enum before). I think ‘Value’Case is better suited for the underlying value (uint) and DataType for the Enum as it shows the data type in text.

  • Added Bytes field for KuraMetric

  • Added DataSet helper constructor

  • Added DataSetValue helper constructors

  • Metric, DataSetValue, Parameter and PropertyValue now inherit from ValueBaseVersionB

This commit heavily refactored the value classes. Please check the attached 'ValueClasses.cd' in the SparkplugNet Project or use this link: https://i.imgur.com/94iHzvf.jpg

- Heavily cleaned/refactored PayloadConverter (number of lines reduced by almost 60%)

- Removed MetricBase
- Added ValueBase class as base for all shared data classes
- Added ValueBase class children for Sparkplug Version A and B
- Added DataTypeExtensions class for converting data types (decoupled it from MetricBase)
- Removed Value property from IMetric (IValue takes care of this now)
- Added interface IValue for value classes

Changed some names for consistency in Value types for A and B:
- Renamed 'Bool' to 'Boolean'
- Renamed 'Integer' to 'Int'
- Renamed 'Type' to 'DataType'
- Added/Renamed ValueCase (uint) and DataType (Enum) as properties for IValue (used this renaming for consistency purposes. Some classes used ValueCase as Enum before). I think ‘Value’Case is better suited for the underlying value (uint) and DataType for the Enum as it shows the data type in text.

- Added Bytes field for KuraMetric
- Added DataSet helper constructor
- Added DataSetValue helper constructors

- Metric, DataSetValue, Parameter and PropertyValue now inherit from ValueBaseVersionB
@BoBiene
Copy link
Copy Markdown
Contributor

BoBiene commented Oct 11, 2022

I am against breaking changes on this large scale

/// <summary>
/// Gets the value.
/// </summary>
public object? Value { get; }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you remove that from the Interface?

@SeppPenner SeppPenner self-assigned this Oct 11, 2022
@SeppPenner
Copy link
Copy Markdown
Owner

I am against breaking changes on this large scale

I'm not completely against the changes, but need to check what has changed first. But in general, I agree. The project should now get into a state where the basic "API" should get more stable, I guess.

@Patrick2607
Copy link
Copy Markdown
Contributor Author

Patrick2607 commented Oct 11, 2022

I am against breaking changes on this large scale

Please take a look at the Class Diagram, I moved it to IValue. I see now that this merge request did not display the link (updated now). The build-up is different, made to adhere to the DRY rule. Instead of having intValue, floatValue, etc. in 5 different classes, it has now been abstracted.

What large-scale breaking changes are you talking about? The only changes to the 'public' are the consistent namings of Boolean in the DataType enums, and consistency in the ValueCase and DataType properties. 99% of the changes I made are under the hood.

@BoBiene
Copy link
Copy Markdown
Contributor

BoBiene commented Oct 12, 2022

I am against breaking changes on this large scale

Please take a look at the Class Diagram, I moved it to IValue. I see now that this merge request did not display the link (updated now). The build-up is different, made to adhere to the DRY rule. Instead of having intValue, floatValue, etc. in 5 different classes, it has now been abstracted.

What large-scale breaking changes are you talking about? The only changes to the 'public' are the consistent namings of Boolean in the DataType enums, and consistency in the ValueCase and DataType properties. 99% of the changes I made are under the hood.

You are right - sorry i just did a quick browser over your code.
I checked out your changes and my integration seem to compile.

@SeppPenner
Copy link
Copy Markdown
Owner

I hope to check this tomorrow, let's see.

@SeppPenner
Copy link
Copy Markdown
Owner

This looks good. I first thought that you changed code from the ProtoBuf generated classes (Which would have been bad), but unifiing the internally used metrics seems to be a very good idea.

@SeppPenner SeppPenner merged commit 68defbf into SeppPenner:master Oct 18, 2022
@Patrick2607
Copy link
Copy Markdown
Contributor Author

@all-contributors please add @Patrick2607 for infrastructure, tests and code

@allcontributors
Copy link
Copy Markdown
Contributor

@Patrick2607

I've put up a pull request to add @Patrick2607! 🎉

@SeppPenner SeppPenner added the enhancement New feature or request label Nov 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants