You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We could enhance and unify Ranges. Currently Min and Max values are allowed but user can want to exclude them. Ex., "Positive" exclude zero. So the "Positive" range looks:
double/float ranges - it is really limitation in ValidRangeAttribute - why we allow it for [int] but block for double/float? - we're provoking customers to use workarounds.
With enumerations the enhancement can be usefull too. Ex., if we want only exclude minimal and maximal values: 1,3,5,7 -> ValidateRange(1,7, ExcludeMin+ExcludeMax) - we accept only 3 and 5. If later we add 2: 1,2,3,5,7 -> ValidateRange(1,7, ExcludeMin+ExcludeMax) - we accept now 2, 3 and 5 without change the attribute.
Features and new apis should be added for the right reasons. It's not enough that someone might need to write some code - here is a very brief list of things I think about when considering new features:
Does the feature introduce or remove complexity for the user?
Does the feature introduce or remove complexity in the implementation?
If the feature introduces complexity - will there be a net benefit? Will it help enough people to justify the feature?
What do we lose in introduce the feature?
In my mind, this feature does not help enough people to justify the time spent reviewing the design and implementation and ensuring it gets tested and documented correctly.
PowerShell has enough users - if nobody has complained about this, you're probably right that they worked around it, but it also tells me it doesn't come up often enough to warrant even one complaint.
Thank you for your deep explanation. It would be good to have in our documentation next to breaking change requirements.
Does the feature introduce or remove complexity for the user? - No and no.
Does the feature introduce or remove complexity in the implementation? - It is short and simple code.
If the feature introduces complexity - will there be a net benefit? Will it help enough people to justify the feature? It is simple. The net benefit is that it closes the only and final omission to get a complete solution. We can't appreciate how many people want this, because now they're using workarounds.
The main difficulty may be to distinguish int anf float parameter types. This can actually create complexity.
A separate question we left in the past PR is that we should remove second code path and implement general ValidateElement method.
I disagree on 1. - it might remove complexity for the rare case, but in the common case, there are additional options that must be considered - so instead of one decision, now I must make two or three.
Often I see unnecessary complexity and I think this happens due to feature creep - adding something seemed reasonable at the time, but the accretion of features results in a mess over the long term.
It's also very subjective. It also gives rise to complexity if it falls short of our expectations. You like Positive/Negative. I would preffer classic math terms:
(a, b)
(a, b]
[a, b)
[a, b]
Activity
iSazonov commentedon Aug 3, 2017
David Christian (@dchristian3188) Please confirm if you plan continue the work.
dchristian3188 commentedon Aug 3, 2017
yes Ilya (@iSazonov) , please assign to me
lzybkr commentedon Aug 3, 2017
I wonder if this is really necessary.
It's only useful for double/float ranges and I don't think those are used very often.
iSazonov commentedon Aug 4, 2017
double/float ranges - it is really limitation in ValidRangeAttribute - why we allow it for [int] but block for double/float? - we're provoking customers to use workarounds.
With enumerations the enhancement can be usefull too. Ex., if we want only exclude minimal and maximal values: 1,3,5,7 -> ValidateRange(1,7, ExcludeMin+ExcludeMax) - we accept only 3 and 5. If later we add 2: 1,2,3,5,7 -> ValidateRange(1,7, ExcludeMin+ExcludeMax) - we accept now 2, 3 and 5 without change the attribute.
lzybkr commentedon Aug 4, 2017
It's really not that useful for doubles because equality is not precise.
I feel like this complicates a simple attribute for little benefit. Enums are usually sequential and it's easier to understand an inclusive range.
As a parallel, the
..operator is always closed and I've never seen a request to support open intervals.iSazonov commentedon Aug 6, 2017
It's not a bug to open immediately a support case. So a script writer just uses a bypass.
lzybkr commentedon Aug 7, 2017
Features and new apis should be added for the right reasons. It's not enough that someone might need to write some code - here is a very brief list of things I think about when considering new features:
In my mind, this feature does not help enough people to justify the time spent reviewing the design and implementation and ensuring it gets tested and documented correctly.
PowerShell has enough users - if nobody has complained about this, you're probably right that they worked around it, but it also tells me it doesn't come up often enough to warrant even one complaint.
iSazonov commentedon Aug 8, 2017
Thank you for your deep explanation. It would be good to have in our documentation next to breaking change requirements.
A separate question we left in the past PR is that we should remove second code path and implement general ValidateElement method.
lzybkr commentedon Aug 8, 2017
I disagree on 1. - it might remove complexity for the rare case, but in the common case, there are additional options that must be considered - so instead of one decision, now I must make two or three.
Often I see unnecessary complexity and I think this happens due to feature creep - adding something seemed reasonable at the time, but the accretion of features results in a mess over the long term.
iSazonov commentedon Aug 9, 2017
It's also very subjective. It also gives rise to complexity if it falls short of our expectations. You like Positive/Negative. I would preffer classic math terms:
(a, b)
(a, b]
[a, b)
[a, b]