Primitive Obsession
To understand what Primitive Obsession is and how to deal with it, let’s remember what primitive types are in a programming language. Primitive types are like the ready-made types that come with the language. You can think of them as straight from the manufacturer. Each language has its own set of primitive types, and since we’re talking about Java here, let’s focus on how it works in Java.
In Java, a primitive type is a type that is already defined in the language and has a special keyword associated with it. Primitive values are independent of each other, they don’t share their state. Java supports eight primitive data types: byte, short, int, long, float, double, Boolean, and char. Along with these eight types, Java also provides special support for strings through the java.lang.String
class. Although the String
class is not technically a primitive data type, it’s given special treatment in the language, so you might consider...