-
Notifications
You must be signed in to change notification settings - Fork 70
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
Simplify value object infrastructure.fs in samples #83
Comments
Firstly, apologies for not taking the time to write a shorter letter, and please keep good questions like this coming! In general, you're correct that this would technically work; For consistency, the following microtweaks would be recommended:
Reformatting:
However the more fundamental issue is that, when running larger Sets of data in the SavedForLater sample, the difference in representation between a 128bit value type and a 32/64 bit reference type is significant to the degree that it produces a noticeable difference in perf running the tests, as alluded to by So... for things like ClientId in the samples, which are not heavily used in lists or Sets, the simplest and most most direct code definitely wins, but for SkuId, these other concerns come into play. For the other types (i.e. aside from |
@chinwobble I hope you'll be happier with #89 - I tried hard to go down the record route, but ultimately not being able to customize constructors etc becomes painful (i.e. having to make a The other benefit is that this approach translates better to C#, and hence hopefully people's understanding when scanning what should be a boring set of types. Definitely thanks for pushing though, this wouldnt have happened without your nudge so much appreciated. (I'll apply these changes to the templates when the dust settles - its not too late to provide more feedback!) |
@bartelink Thanks for your effort! Its ashame that these values objects can't be more succinctly represented in the language. |
After some pushing it around this morning with Eirik, I reached a conclusion (out of band) that they can and should be. The reason we ended up with the Requestid and CartId still being custom types is to represent a case where In the original implementation, we'd conflated the canonicalization need with the the storage need. As a result, there's a need to ensure the canonicalization and conversion takes place at the time of (de)serialization. The resolution is that we'll recommend in any such case to bring in an intermediate/upconversion layer to the decoding step:-
The normal case will be that a strongly typed e.g. This upconversion / Anti Corruption Layer slots in with stuff one'd do in line with requirements in various cases discussed in https://leanpub.com/esversioning The other thing this ties in with is that for json-encoded schemes, even if something is technically a Guid, that's not a very idiomatic way to encode such data (especially when the expectation is that it represents a natural identifier), so a string is just fine. The thing that needs to be borne in mind by those writing any anticorruption layer and/or binding later externally is that one should do a length sanity check and/or xss check before generating a Finally, best of all, the project for the strongly typed ids has been moved to fsprojects:- https://github.com/fsprojects/UnitsOfMeasure.Extra - when the NuGet arrives, I'll do the port, which will make most of the accidental confusing junk you so rightly called out melt away in the |
Fixed in release 1.0.4
|
thanks for the nudge @chinwobble - I'll let you close at your leisure |
Closing for age - thanks again; feel free to comment or add notes when you review @chinwobble |
In the sample project we have SkuId as a value object implemented as a class hat inherits a
Comparable
Can this be simplified to a record type like this?
The text was updated successfully, but these errors were encountered: