Doing this calculation might seem like the thing to do at first glance, though it ultimately is knowledge going in the wrong direction. The field determines how big it should be, and the thing creating the value for the field should cater to that. Not the other way around. Making the max size in the StringHasher class configurable would allow for having the thing once, though that would be introducing functionality that is not really needed. (I'm not opposed to adding that, I just don't think it is worthwhile in this case)