From the course: Go Design Patterns
Unlock the full course today
Join today to access over 24,700 courses taught by industry experts.
Builder pattern overview - Go Tutorial
From the course: Go Design Patterns
Builder pattern overview
- [Instructor] The builder pattern is a very common creational design pattern. Its main purpose is to encapsulate and simplify the creation of complex objects, which makes it much easier to create objects that can have many different representations. It also helps to make the construction code more readable, which is really helpful when the objects constructor has a lot of optional parameters or parameters of the same type. And since the object isn't actually constructed until the builder creates it, the problem of having an object be in an inconsistent or invalid state can be prevented. This kind of pattern is useful in scenarios where the object being created has a complex API with many different constructors or properties and where there's a diversity of valid states that the object can be in, depending upon the values of those properties. Using a builder pattern is pretty straightforward. We have a director object,…
Contents
-
-
-
-
(Locked)
Builder pattern overview1m 52s
-
(Locked)
Builder pattern example9m 58s
-
(Locked)
Factory pattern overview1m 40s
-
(Locked)
Factory pattern example6m 12s
-
(Locked)
Singleton pattern overview2m 10s
-
(Locked)
Basic Singleton pattern example3m 17s
-
(Locked)
Making Singleton concurrent-safe3m 44s
-
(Locked)
-
-
-