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.
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