When to and When Not to Use Enums in Java | by daleef rahman | Feb, 2022

Are enums a code smell?

daleef rahman
Photo by Blake on Unsplash
Class representation of the Enum “Houses”
Example taken from https://docs.oracle.com/javase/tutorial/java/javaOO/enum.html

Type safety

Globalisation

Enums force you to use multiple switch case

Example from Clean Code: A Handbook of Agile Software Craftsmanship (Robert C. Martin)
Example from Clean Code: A Handbook of Agile Software Craftsmanship (Robert C. Martin)

Enums leads to suboptimal modeling

Leave a Comment