Should I ever use Enums as discriminators?

前端 未结 2 1463
死守一世寂寞
死守一世寂寞 2021-01-13 10:18

When do Enumerations break down?


To support a new feature in an existing system, I was just considering implementing some form of discriminator to an entity ta

2条回答
  •  误落风尘
    2021-01-13 10:47

    Those Enumeration Classes look neat, I've often looked jealously at Java's enums.

    I think the usual rules apply: do the Simplest Thing That Could Possibly Work. If you find yourself with more than one switch on the enum, then that's a smell, and time to consider the pattern you've found.

    Otherwise, why burden yourself with something you don't need?

提交回复
热议问题