免费学习该课程!
今天就开通帐号,24,700 门业界名师课程任您挑!
Proxy example
- [Tutor] Let's first define our producer class. We expect it to be more resource intensive when we are trying to instantiate it. Here, being resource intensive means using more computing resources, such as memory or CPU. The producer class prints the messages shown here. There are two methods defined. The first one is printing the current status of the producer, stating, "Producer is working hard!" The second method prints a statement saying that the producer now has time to meet a guest. The goal here is not to bother the producer until the producer is available, because the producer is very expensive to instantiate. Next, let's define the proxy class. The proxy class is relatively less resource intensive when instantiated. That's why we use the proxy object as a middle person to handle the request for the producer until the producer becomes available. Let's see what happens in the proxy class. We have two attributes. One is occupied. The default value for that attribute is no. We…
内容
-
-
-
-
-
(已锁定)
Decorator1 分钟 5 秒
-
(已锁定)
Decorator example4 分钟 43 秒
-
(已锁定)
Solution: Decorator1 分钟 55 秒
-
Proxy1 分钟 22 秒
-
(已锁定)
Proxy example5 分钟 23 秒
-
(已锁定)
Adapter48 秒
-
(已锁定)
Adapter example6 分钟 16 秒
-
(已锁定)
Composite1 分钟 21 秒
-
(已锁定)
Composite example5 分钟 25 秒
-
Solution: Composite1 分钟 44 秒
-
(已锁定)
Bridge1 分钟 14 秒
-
(已锁定)
Bridge example5 分钟 31 秒
-
(已锁定)
-
-
-