Enum vs String as a parameter in a function

I think enums are safer especially for larger systems with multiple developers.

As soon as the need arises to change the value of such an enum, looking up and replacing a string in many places is not my idea of fun 🙂

The most important criteria IMHO is the usage: for use in a module or even a package a string seems to be fine, in a public API I’ld prefer enums.

Leave a Comment