There are two possible cases here, and unfortunately your example is too simplified to tell which one of the two applies in your question:
- The parameter types represent some domain concept.
- The parameters actually are
String
s.
In case #1, the types shouldn't have been String
s to begin with, they should have been domain types, such as FirstName
, LastName
, or Address
. Darren Hobbs calls this the Tiny Types Pattern, but really, it's just correct design.
In case #2, what you are proposing is just wrong. The parameters are String
s, so their type should be String
.
However, at least in case #2, it is highly likely that this piece of code violates some other guideline of good design and is, for example, doing too much work. Or, the parameters actually have a relationship with each other and shouldn't be separate parameters but rather an object.
I challenge you to give a real example of a method that takes 4 String
s as parameters and isn't violating good design somewhere. You might want to read the discussion about the Zero, One, Infinity Rule on the Wiki. @Steve Chamaillard mentioned the relationship to Object Callisthenics in his comment.
Note: As @Derek Elkins mentioned in his comment, the fact that you made your wrapper types mutable whereas the original type (String
) is immutable, completely changes the semantics of the code! In my answer, I am assuming this mistake is corrected and the setter removed. (Veering off into very opinionated territory here, I suggest that you should never have setters, period.)