Both the function option pattern and builder pattern are super operative design patterns. But as a software engineer, it is so important to use this pattern in the right conditions. In this article, I want to say that using the function option instead of the builder pattern is wrong.
When using the Function option pattern
when we have a lot of parameters that they are optional, it is much better to use this pattern.
Builder pattern
Golang Builder Design Pattern
I saw that some developers used the function option pattern for sending many optional parameters as input and it is true. But when we need to set a parameter and it is essential why get these parameters as an optional function design pattern? For example, we need to build a house. In simplest abstraction, we need a roof, wall, and door. Although we can set a default value for all of these three elements and get them by function option pattern in many cases, we don’t have a default value for them. In this case, it is much better to use the builder pattern and after defining all parameters, build a decided apartment, even in the builder pattern we can check everything will be ok. For example, we can check a The door matches the window.