Effective Java! Prefer Class Hierarchies to Tagged Classes

Kyle Carter
3 min readJan 11, 2021

It seems like a lot of the previous chapters of Effective Java have shared some concerns with using all the capabilities that object-oriented programming offers us. There are indeed pitfalls with over using some of the functionality of these patterns so they should be used with prudence. Today, however, we look at a topic where object-oriented programming can come to the rescue.

Let’s start out by looking at the following class.

class Figure {
enum Shape {CIRCLE, RECTANGLE}

--

--

Kyle Carter

I'm a software architect that has a passion for software design and sharing with those around me.