Skip to content
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

Document OrderIdComponents etc rationale #173

Open
nickevansuk opened this issue Nov 30, 2021 · 0 comments
Open

Document OrderIdComponents etc rationale #173

nickevansuk opened this issue Nov 30, 2021 · 0 comments

Comments

@nickevansuk
Copy link
Contributor

Question: Should OrderidComponents (and probably SellerIdcomponents too...) should be generic in TId instead of having OrderIdLong and OrderIdString properties on it?

Answer: the issue we found previously was that using that was it requires binding TId in the classes that use it, and given it’s used in so many places that ends up requiring quite a bit of wiring up - similar to how complex TBookableIdComponents / IBookableIdComponents is. So I think it’s one of those things that’s a combinatorial explosion of complexity when you get into it

If it was possible to just reference OrderIdComponents<> everywhere (i.e. unbound generics) then would be easy, though I didn’t think that was possible last time I checked… which means you end up creating an IOrderIdComponents interface to use everywhere instead and converting between them

Further investigation: If e.g. {OrderItemIdString} is used in the UriTemplate, when the implementer meant to use {OrderItemIdLong}, this can cause some harder to debug errors. Is it possible to apply some validation to ensure that OrderItdComponents is only used in one of the 3 modes within a particular implementation - perhaps by adding validation logic to the IdTemplate parsing, or use generics in some other way to achieve a configurable yet strongly typed approach.

As a basic example, it could throw an exception if e.g. a value is present in OrderItemIdLong, and an attempt is made to read OrderItemIdString, an exception could be thrown "this is not the value you are looking for".

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

No branches or pull requests

1 participant