Hacker News new | past | comments | ask | show | jobs | submit login

Don't use a raw integer as the ID type. Use different types for different IDs: UserId, OrganizationId, etc.

It's a common bug to get different ID types mixed up, and a gigantic offset will do nothing to help you with that.




I agree, the 'microtype' pattern can be a good way of getting the type-checker to catch silly mistakes.

In Ada it's standard practice. In C++ you really need a library to do it easily, but there's a good one out there ready to go:

https://github.com/foonathan/type_safe/




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: