From the course: Go Design Patterns
Unlock the full course today
Join today to access over 24,700 courses taught by industry experts.
Factory pattern overview - Go Tutorial
From the course: Go Design Patterns
Factory pattern overview
- [Instructor] In this example, we're going to look at the factory design pattern, which is also fairly common in software development today. This particular pattern defines a way for a program to create objects at runtime without having to specify the exact class or type of the object to be created. This allows us to decouple the creation of an object from the definition of the object itself. This approach has some advantages. For example, it's useful in scenarios where the factory method can produce more readable code when there are multiple different ways of creating an object. In using this approach, it is also possible to create objects without having to know their exact type beforehand. Your code simply specifies some parameters and then the right type of object is created. So let's take a look at the diagram for the factory pattern. There's a creator interface that defines a factory method, which ensures that the…
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)
-
-
-