This actually have a pattern name, but it is ugly and confusing: Flyweight factory