I recently studied design patterns in a research team and realized that a builder pattern can be very useful for creating complex objects that consist of many (potentially optional) parts.
However, is there ever a moment when a builder does too much? Say we have a class that has many different combinations of objects, is there another template that might be better suited for this, instead of creating dozens of different developers? Is it possible to reduce the number of builders that you need without creating completely specific builders?
An example of my research team, and I kept coming back, was an auto builder, for example, on a car company website. Any car company has dozens of cars, each of which has many different functions, colors, additions, etc. As I understand it, your builder should be specific to the specific object that you are doing, so applying a builder pattern to this example will give hundreds of builders that look like "RedSUVWithSunroofBuilder", "BlueSUVWithSunroofBuilder", "RedSUVBuilder, etc.
Is there any reason that, using the builder pattern, I could not pass some of these values in order to reduce the number of developers that I would need to create? For example, instead of having RedSUVWithSunroofBuilder or BlueSUVWithSunroofBuilder, is the build template still suitable for SUVWithSunroofBuilder ("Red") and SUVWithSunroofBuilder ("Blue"), or is it more suitable for another template?
source
share