-
Notifications
You must be signed in to change notification settings - Fork 393
Absolute Values of Quantities #325
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
Comments
I hope this doesn't come across as rude, but do you mean "Absolute" instead of "Abstract"? |
You probably refer to absolute. Sure, this is probably convenient, but I do question how often this adds value since it's a matter of a bit more syntax to achieve the same thing and it will increase the library size linearly with the number of quantities. I'm really worried about the size of the library lately (nearing the 1MB mark) and am hesitant to add anything that is not essential, frequently used or solves something that is truly cumbersome to do outside the library. I'm starting to think this is actually another argument for a common quantity interface + extension method or an abstract base quantity type, to avoid duplicating the implementation N times. Discussed in #308 . So, I think I currently lean towards only implementing this if we do it via abstract base type or extension method. |
Was working overtime a lot lately. And when I'm tired, I do these kind of silly mistakes :) Yeah it should be absolute value instead of abstract value. I feel that getting absolute values easily is an essential feature for a quantity library, because the whole point of UnitsNet is to make dealing with quantities easy, right? But also as you said, if it costs O(n) space, not feasible. If we would have a base abstract class it would be O(1) space. So I agree that we should deal with #308 first. |
I am closing this due to inactivity, please reopen if you plan to pursue this further. As noted in #302 , we can possibly do also add this to our |
We can improve readability, writeability and maybe also performance (by avoiding unnecessary
.Meters
and.FromMeters
) if we provide conversion to abstract.As-is:
Length abstractLength1 = Length.FromMeters(Math.Abs(length1.Meters))
To-be:
Length abstractLength1 = length1.ToAbstract()
What do you think?
The text was updated successfully, but these errors were encountered: