dimanche 18 avril 2021

Use of strings vs enums as parameter of factory method?

I was recently reading this blog https://blog.cleancoder.com/uncle-bob/2021/03/06/ifElseSwitch.html and this paragraph confused me:

Be careful with that token x. Don’t try to make it an enum or anything that requires a declaration above the red line. An integer, or a string is a better choice. It may not be type safe. Indeed, it cannot be type safe. But it will allow you to preserve the component structure of your architecture.

If we declare an enum in the higher level module, wouldn't it still be that the low level module depends on the high level module? If so,then what is wrong in using an enum in this case?

Aucun commentaire:

Enregistrer un commentaire