ThreeDotsLabs / wild-workouts-go-ddd-example

Go DDD example application. Complete project to show how to apply DDD, Clean Architecture, and CQRS by practical refactoring.
https://threedots.tech
MIT License
5.14k stars 472 forks source link

Using string constants as enums #12

Closed blaggacao closed 3 years ago

blaggacao commented 3 years ago

What would be wrong with this approach? — it looks a bit more concise

blaggacao commented 3 years ago

It also would buy us evasion of another specialty implementation for #11

m110 commented 3 years ago

Hey @blaggacao. We use the structs approach for type safety in the domain. While your example works in a similar way, you can't prevent someone from passing UserType("any-string") as UserType argument. With the current approach, you can't set the unexported struct field from outside the package.

blaggacao commented 3 years ago

@m110 Thank you very much for the context!