Skip to content

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

Closed
0xferit opened this issue Nov 23, 2017 · 4 comments
Closed

Absolute Values of Quantities #325

0xferit opened this issue Nov 23, 2017 · 4 comments
Labels

Comments

@0xferit
Copy link
Contributor

0xferit commented Nov 23, 2017

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?

@0xferit 0xferit changed the title Abstract Value of Quantities Abstract Values of Quantities Nov 23, 2017
@JKSnd
Copy link
Contributor

JKSnd commented Nov 23, 2017

I hope this doesn't come across as rude, but do you mean "Absolute" instead of "Abstract"?

@angularsen
Copy link
Owner

angularsen commented Nov 23, 2017

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.

@0xferit 0xferit changed the title Abstract Values of Quantities Absolute Values of Quantities Nov 24, 2017
@0xferit
Copy link
Contributor Author

0xferit commented Nov 24, 2017

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.

@angularsen
Copy link
Owner

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 IQuantity<T> interface, but I'm not sure I feel the effort is worth the slight improvement in syntax.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants