-
Notifications
You must be signed in to change notification settings - Fork 393
Why don't we have a base class for quantities? #308
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 agree, I've just been waiting for the right real-world usecase and the right person with the motivation to get it done - solving a real need. |
I am planning to give you a proposal in detail when I have time, but for instance I remember we had to do reflection hack because of lacking a base For example, we have a list view control which lists (prints their name, or abbreviation) units of a given quantity. However, as we don't know which quantity we are dealing with, we want a List like this: So instead, we had to do Similarly we could keep a To be able to demonstrate my arguments easily I'm working on a converter app. I'll share it soon. |
Since the quantities are structs I've been worried by the boxing overhead of using an interface, but if the alternative is using an |
@ferittuncer Looking forward to the pseudo code, as generally in these cases I have found that it's unnecessary to work "blindly" with the units. You usually know what quantity the units are for since you typically want to be able to convert to other units at some point. There is also a |
@eriove Right, and I guess performance is perhaps not the primary focus if you have already resorted to reflection to achieve this :-) If I was writing performance sensitive code, I would not use Units.NET, but rather custom types tailored for my need. |
Closing this in favor of #371 |
Wouldn't it be beneficial to move common things in quantity classes to a quantity base class?
Sometimes we don't know which quantity we are dealing with, but we want to print them, or get abbreviations etc. which is common in all quantities. This use case is important especially in GUI development.
What are your thoughts?
The text was updated successfully, but these errors were encountered: