-
Notifications
You must be signed in to change notification settings - Fork 19
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
Study the possibility of using Vogen to fix Primitive Obsession with Segment/Offset, paths, and other values #372
Comments
I have nothing against Vogen, but I don't think it solves the examples you mentioned? Good variable, parameter and method names should be able to take care of these problems. |
Yes, maybe I misinterpreted what Vogen is capable of. |
No idea what this is, but Vogen helps distinguish between ambiguous primitives and real world types. If a method parameter is of type 'Segment', then the compiler will tell you if you pass an 'Offset'. It may be that your API accepts either, in that case, you can use Happy to elaborate further, but it sounds like Vogen is exactly the the kind of thing to differentiate between ambiguous primitives and domain concepts |
Thanks Steve.
Both segment and offset are 16 bit unsigned integers in the range 0x0000 to
0xFFFF
The problem is that they are stored in our source systems as 2 16-bit words
in 2 different ways.
Offset:segment and segment:offset
Sometimes it's not obvious which one is which and we end up using the
offset word as the segment and the segment word as the offset.
There's no way for Vogen to know which is which.
…On Wed, Jul 19, 2023, 20:37 Steve Dunn ***@***.***> wrote:
No idea what this is, but Vogen helps distinguish between ambiguous
primitives and real world types. If a method parameter is of type
'Segment', then the compiler will tell you if you pass an 'Offset'.
It may be that your API accepts either, in that case, you can use Either<Segment,
Offset>
Happy to elaborate further, but it sounds like Vogen is exactly the the
kind of thing to differentiate between ambiguous primitives and domain
concepts
—
Reply to this email directly, view it on GitHub
<#372 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABHYKTXU6ID3RKSZ32X45Y3XRASP5ANCNFSM6AAAAAA2CDFCXM>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Vogen can still be used to strongly enforce usage, like hostPath and dosPath strings usage in our |
Is your feature request related to a problem? Please describe.
Sometimes, we use Segment instead of Offset or vice-versa, because both are ushort values.
Sometimes, we pass the DosFileManager a dosPath instead of a hostPath or vice-versa, because both are string values.
Describe the solution you'd like
Make the compiler raise an error before runtime. With this package:
https://github.com/SteveDunn/Vogen
Describe alternatives you've considered
Use classes instead, I guess.... But Vogen can generate the boring boiler plate code.
Additional context
None.
The text was updated successfully, but these errors were encountered: