Can you spot any code smells? We think you should be able to find Primitive Obsession. Refactor to remove it.
If you want to really practice doing refactorings safely, you'll want to do it in a series of small, safe steps. This is the outline of a path that will take you there:
- Encapsulate Variable on the "personalNumber" field.
- Replace Primitive with Object on the "personalNumber" field. You'll create a class "PersonalNumber".
- Move Function to move the "birthYear" function to the "PersonalNumber" class.
At this point you should have fixed the primitive being used for the swedish personal number.
- Repeat the steps for the phoneNumber field. Create a class PhoneNumber and move countryCode to it.
- Repeat the steps for the role field. Create a class Role and move canDeleteUsers to it.