Slowers-Team / Slowers-App

MIT License
2 stars 0 forks source link

Roles as enums in backend #85

Open Halmela opened 2 weeks ago

Halmela commented 2 weeks ago

Currently each role in backend is a hardcoded string and every time they are used, the validity of role has to be validated manually. Currently this is not much of an issue, since only few parts of the codebase actually work with roles, but every addition creates multiple lines of code that is prone to future breakage.

I propose that roles would instead be handled as enums. This would add consistency in handling roles and as an extra benefit it would reduce the memory footprint, because integers are less expensive to store than strings. Enums also provide some compile time guarantees for type safety and are easily debuggable.

Go by Example: Enums

Halmela commented 2 weeks ago

I think we can put this on hold. It would add too much complexity without much gains.