Magic type wrapping. #3597
Ben-PH
started this conversation in
Code Style
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In a similar vein to how magic-numbers is a code smell, to what extent are magic-types the same?
In
BootstrapConfig
, there are many fields that are int-primitives:What prompted this discussion was a minor restructure I'm working on meant that I had to be careful about which field/variable I was working with. Using this wrapper would mean that it is less likely for people to accidently mix things up when they have the same primitives.
would it be worth it to, for example make
thread_count
aThreadCount(pub u8)
? and similar to other fields?I think the value of this exists as a spectrum. I think
ThreadCount
is a good example of where it would be useful as it adds more self-documentation to the code-base at large, but in some use-cases, it's just code-bloat.If nothing else, I home this discussion gives food for thought to my fellow devs.
Beta Was this translation helpful? Give feedback.
All reactions