In this part of my code refactoring tutorial, we’ll look at how to replace a primitive type with a class.

Type safety is very important! So, what we want to do is to eliminate all operations on values that are not of the appropriate data type by protecting the program from bad input. One way we can do this is by replacing primitive types with classes. I’ll walk you step-by-step through the process. The code below will help you along.