How would be the best way to apply this pattern?
In general such questions are open and often directed by opinions. But I would say that it applies better by following a reliable source (already demonstrated in the comments that Wikipedia in Portuguese is not).
Do you want an opinion? I’ve never seen a need for it, at least in this form, but it’s just my experience. But there is one my question that gives an example where it might be necessary. There are more explained examples.
Possible reliable sources:
It is very easy to confuse it with other patterns (incidentally almost all patterns are very similar among some groups).
Why should I use this pattern? When should I use it? Why is it good?
Use when you have very complex objects and they need to be built in different ways before using it, usually built in steps. But not only that, it only makes sense if you have several objects that have the same basic construction mechanism, but with different implementation details. I don’t think it’s good, it’s really bad, but if you have that need then you have to use it and this shape was what they thought was best, I don’t know if it really is.
Something similar to it may be more useful in some cases where you just create the construction separately in a simple way just to separate the responsibility and allow the construction in steps without conforming to a pattern. Even in such cases it is only useful if the construction is very complex.
How would be a wrong way to make this pattern?
Hard to answer that, there are literally millions or billions of different ways to do it wrong. And I don’t even know if it would be wrong. I always say you should do what you do best, even if it violates some pattern.
Not to be confused with Method Chaining which is a very different pattern but which is used for a construction, and can even be used together with the Builder. This I see being much more used (I don’t even know if I should, but for language failures it has been common).
There are flaws in this pattern?
Certainly, unfortunately, I’m no expert on him to say, I hope someone can. What I can say is that it always adds a lot of complexity, needs to compensate a lot to use it, for me is the biggest flaw. And it certainly doesn’t solve every situation.
Something else to add?
Always has, but nothing that I think important. remembering that this is the very little used pattern and by very few dominated.
Could add the Wikipedia link on this pattern to provide more context?
– gato
The wikipedia article cited in the question is not a good example on the Builder standard.
– Leonardo Lima
For me, this code of
Converter
looks more like the strategy standard. To wikipedia in English has a better example of Builder– hkotsubo
Did the answer resolve what was in doubt? Do you need something else to be improved? Do you think it is possible to accept it now?
– Maniero
@Could Leonardolima show why it is not a good example and what would be a good example for it? This would answer question 1 and 3.
– Felipe Jorge