The general problem you're facing here is the problem of building complex objects based on some parameters/inputs, which can be solved via a design pattern known as the builder pattern.
Though implementing such patterns can make your code look a bit complex (take this for example), here's my very simple…
Top comments (0)