1 00:00:00,900 --> 00:00:06,780 The template method pattern provides a framework for implementing an algorithm, providing a default 2 00:00:06,780 --> 00:00:10,680 implementation that can be later on modified in subclasses. 3 00:00:11,820 --> 00:00:17,650 Let me clear this out a little bit, suppose that you need to create an algorithm for assembling a computer. 4 00:00:18,510 --> 00:00:24,060 Essentially, you have a method for replacing the motherboard, a method for assembling the memory to 5 00:00:24,060 --> 00:00:30,450 the motherboard, one for attaching the processor, so on and so forth for all the other components 6 00:00:30,450 --> 00:00:31,170 of a computer. 7 00:00:32,540 --> 00:00:38,300 Using this pattern, we provide a common way for assembling a computer, but if something in the architecture 8 00:00:38,300 --> 00:00:42,170 of a computer changes, we can modify that template class in a subclass. 9 00:00:42,380 --> 00:00:46,150 But essentially the sequence of operations will remain the same. 10 00:00:47,310 --> 00:00:49,590 Here is the UML diagram for this pattern. 11 00:00:50,570 --> 00:00:54,590 We have the computer template, abstract class alongside all its methods. 12 00:00:55,760 --> 00:01:00,260 We extend this class in a tower, computer class and a quantum computer class. 13 00:01:01,310 --> 00:01:06,020 Those two classes will extend the template class, however, they will provide some elements that are 14 00:01:06,020 --> 00:01:07,340 specific to their types. 15 00:01:08,300 --> 00:01:10,220 Let's see how this looks like in the code.