I’m new in Design Patterns so I have one question about the Builder Pattern.
Today I heard that Builder Pattern is different from the class StringBuilder in Java, C#. I know that main goal of the Builder Pattern is to create complex objects in few steps…I think that this is making StringBuilder with it’s method Append…So it’s hardly for me to find the difference…
Could you tell me is there really any difference and if it is…what’s it :)?
It sounds like you might be confusing the class StringBuilder and the Builder Design Pattern. They are actually two very different ideas.
StringBuilder is a class in Java and .NET that allows more performant string operations: (From MSDN)
The Builder Pattern on the other hand is a design pattern which is a set of classes and/or interfaces meant to organize complex code:
The
Appendmethod ofStringBuildersimply adds more characters to the existing string. There are no new objects created (basic function of the builder pattern) and there is no design pattern involved. It’s a single method call to a single object instance.