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

Study the possibility of using Vogen to fix Primitive Obsession with Segment/Offset, paths, and other values #372

Open
maximilien-noal opened this issue Jul 7, 2023 · 5 comments
Labels
enhancement New feature or request low priority Fixing this is not urgent, or would take too much manpower for too little gain refactoring Involves refactoring existing code

Comments

@maximilien-noal
Copy link
Member

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.

@maximilien-noal maximilien-noal added enhancement New feature or request low priority Fixing this is not urgent, or would take too much manpower for too little gain refactoring Involves refactoring existing code feature request This would be good to have labels Jul 7, 2023
@JorisVanEijden
Copy link
Contributor

I have nothing against Vogen, but I don't think it solves the examples you mentioned?
The classes have no way of knowing if 0x1234 represents a segment or an offset.
Same with the paths, "/home" can be either a host or a dos path.

Good variable, parameter and method names should be able to take care of these problems.

@maximilien-noal
Copy link
Member Author

Yes, maybe I misinterpreted what Vogen is capable of.

@maximilien-noal maximilien-noal changed the title Study the possibility of using Vogen to fix Primitive Obsession with Segment/Addresses, paths, and other values Study the possibility of using Vogen to fix Primitive Obsession with Segment/Offset, paths, and other values Jul 8, 2023
@SteveDunn
Copy link

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

@JorisVanEijden
Copy link
Contributor

JorisVanEijden commented Jul 19, 2023 via email

@maximilien-noal
Copy link
Member Author

maximilien-noal commented Jul 20, 2023

Vogen can still be used to strongly enforce usage, like hostPath and dosPath strings usage in ourinternal APIs.

@maximilien-noal maximilien-noal removed the feature request This would be good to have label Jul 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request low priority Fixing this is not urgent, or would take too much manpower for too little gain refactoring Involves refactoring existing code
Projects
None yet
Development

No branches or pull requests

3 participants