今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Builder pattern example
- [Instructor] For this example, we're going to use the builder pattern to create a notification object, which represents the kind of notification pop-up message you might see on your phone or desktop computer. The notification 'Go file' contains the definition of the notification struct that the builder will create. Note that all the fields are lowercase, which means that they are not exported from this struct which makes the notification type effectively immutable, unless you provide methods to change the fields, which I haven't. So this is one of the advantages of using a builder. You can make the finished object immutable pretty easily. All right, so now let's take a look at the builder code. Here in the builder.Gofile I have the notification builder struct along with several methods that are used to modify the builders properties and a function named new notification builder. And if I scroll down a bit, we can see…
内容
-
-
-
-
(已锁定)
Builder pattern overview1 分钟 52 秒
-
(已锁定)
Builder pattern example9 分钟 58 秒
-
(已锁定)
Factory pattern overview1 分钟 40 秒
-
(已锁定)
Factory pattern example6 分钟 12 秒
-
(已锁定)
Singleton pattern overview2 分钟 10 秒
-
(已锁定)
Basic Singleton pattern example3 分钟 17 秒
-
(已锁定)
Making Singleton concurrent-safe3 分钟 44 秒
-
(已锁定)
-
-
-