title
Command Design Pattern
description
Code is Here: http://goo.gl/haF7p
Best Design Patterns Book : http://goo.gl/W0wyie
Welcome to my Command Design Pattern Tutorial! The Command design pattern allows you to store a list of commands for later use. With it you can store multiple commands in a class to use over and over.
I cover the basic pattern in numerous ways including descriptions, diagrams and code. We look into executing commands on numerous objects. We also explore how to undo commands.
All of the code is above. Between it and the video you should be an expert on the Command Pattern.
detail
{'title': 'Command Design Pattern', 'heatmap': [{'end': 74.365, 'start': 39.976, 'weight': 0.709}, {'end': 600.359, 'start': 577.108, 'weight': 0.715}, {'end': 679.487, 'start': 625.489, 'weight': 0.838}, {'end': 729.166, 'start': 695.979, 'weight': 0.865}], 'summary': "Covers the command design pattern in multiple ways, including a simple definition, walkthrough, uml diagram, and code explanation, ensuring comprehensive understanding. it explains the behavioral pattern used to encapsulate method calls, allowing for execution at a later time, with the capability to undo commands and transfer commands from an invoker to a receiver. additionally, it demonstrates practical implementations in java for creating a television receiver, implementing turn tv off functionality, device control with commands, and remote control for electronic devices, showcasing the pattern's advantages and its usage in controlling multiple devices.", 'chapters': [{'end': 223.348, 'segs': [{'end': 74.365, 'src': 'heatmap', 'start': 0.129, 'weight': 0, 'content': [{'end': 3.672, 'text': 'Well hello internet and welcome to part 12 of my design patterns video tutorial.', 'start': 0.129, 'duration': 3.543}, {'end': 6.655, 'text': "Today we're going to talk about the command design pattern.", 'start': 3.712, 'duration': 2.943}, {'end': 8.836, 'text': "I'm going to show you this in numerous different ways.", 'start': 6.715, 'duration': 2.121}, {'end': 10.798, 'text': "I'm going to explain it as a simple definition.", 'start': 9.037, 'duration': 1.761}, {'end': 13.5, 'text': "I'm going to explain it as a walkthrough just using words.", 'start': 10.818, 'duration': 2.682}, {'end': 15.402, 'text': "Then I'm going to show you a UML diagram.", 'start': 13.781, 'duration': 1.621}, {'end': 17.524, 'text': "Then on top of that I'm going to show you all of the code.", 'start': 15.442, 'duration': 2.082}, {'end': 20.846, 'text': 'And then on top of that all the code is available underneath the video.', 'start': 17.764, 'duration': 3.082}, {'end': 26.231, 'text': 'So if you go through all five or six of those steps, I guarantee you will understand the command design pattern.', 'start': 20.887, 'duration': 5.344}, {'end': 27.132, 'text': "So let's get into it.", 'start': 26.251, 'duration': 0.881}, {'end': 29.113, 'text': 'So what is the command design pattern??', 'start': 27.612, 'duration': 1.501}, {'end': 39.756, 'text': 'Well, the basic definition is the command design pattern is a behavioral design pattern in which an object is used to represent and encapsulate all the information needed to call a method at a later time.', 'start': 29.133, 'duration': 10.623}, {'end': 44.917, 'text': 'This information includes the method name, the object that owns the method, and the values for the method parameters.', 'start': 39.976, 'duration': 4.941}, {'end': 49.138, 'text': "Now if that didn't make any sense, let's move on and explained in a completely different way.", 'start': 44.977, 'duration': 4.161}, {'end': 56.24, 'text': 'Basically, what it allows you to do is store lists of codes that are executed at a later time or many times, and on top of that,', 'start': 49.198, 'duration': 7.042}, {'end': 60.281, 'text': "normally with the command design pattern, there's a capability for you to undo commands.", 'start': 56.24, 'duration': 4.041}, {'end': 74.365, 'text': 'Basically, what happens is the client or the application part of your program says I want a specific command or a list of code to be executed whenever a method called execute is called on one of these encapsulated hidden objects.', 'start': 60.481, 'duration': 13.884}], 'summary': 'Part 12 covers the command design pattern, explaining it in multiple ways and providing code examples.', 'duration': 60.152, 'max_score': 0.129, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7Pj5kAhVBlg/pics/7Pj5kAhVBlg129.jpg'}], 'start': 0.129, 'title': 'Command design pattern', 'summary': 'Covers the command design pattern in multiple ways, including simple definition, walkthrough, uml diagram, and code explanation, ensuring comprehensive understanding. it also explains the command design pattern, a behavioral design pattern used to encapsulate method calls, allowing for execution at a later time, with the capability to undo commands, and the transfer of commands from an invoker to a receiver.', 'chapters': [{'end': 29.113, 'start': 0.129, 'title': 'Design patterns video tutorial', 'summary': 'Covers the command design pattern in multiple ways including simple definition, walkthrough using words, uml diagram, and code explanation, ensuring comprehensive understanding.', 'duration': 28.984, 'highlights': ['The chapter covers the command design pattern in numerous different ways, including simple definition, walkthrough using words, UML diagram, and all of the code.', 'The code for the design pattern is available underneath the video, ensuring comprehensive understanding.', 'The tutorial guarantees a full understanding of the command design pattern by going through all the provided steps.']}, {'end': 223.348, 'start': 29.133, 'title': 'Command design pattern explained', 'summary': 'Explains the command design pattern, a behavioral design pattern used to encapsulate method calls, allowing for execution at a later time, with the capability to undo commands, and the transfer of commands from an invoker to a receiver.', 'duration': 194.215, 'highlights': ['The command design pattern is used to encapsulate method calls, allowing for execution at a later time. The pattern allows for the storage of lists of codes that are executed at a later time or multiple times.', 'The capability for undoing commands is a key feature of the command design pattern. The pattern provides the capability to undo commands, enhancing its flexibility and usefulness in certain scenarios.', 'The transfer of commands from an invoker to a receiver is a fundamental aspect of the command design pattern. The pattern involves the invocation of a command by the client, which is then transferred to an object called the receiver for execution.']}], 'duration': 223.219, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7Pj5kAhVBlg/pics/7Pj5kAhVBlg129.jpg', 'highlights': ['The tutorial guarantees a full understanding of the command design pattern by going through all the provided steps.', 'The code for the design pattern is available underneath the video, ensuring comprehensive understanding.', 'The chapter covers the command design pattern in numerous different ways, including simple definition, walkthrough using words, UML diagram, and all of the code.', 'The capability for undoing commands is a key feature of the command design pattern. The pattern provides the capability to undo commands, enhancing its flexibility and usefulness in certain scenarios.', 'The transfer of commands from an invoker to a receiver is a fundamental aspect of the command design pattern. The pattern involves the invocation of a command by the client, which is then transferred to an object called the receiver for execution.', 'The command design pattern is used to encapsulate method calls, allowing for execution at a later time. The pattern allows for the storage of lists of codes that are executed at a later time or multiple times.']}, {'end': 501.484, 'segs': [{'end': 255.929, 'src': 'embed', 'start': 223.368, 'weight': 0, 'content': [{'end': 227.59, 'text': "Well, it allows you to set aside a list of commands for later use, like I've mentioned before.", 'start': 223.368, 'duration': 4.222}, {'end': 233.412, 'text': 'On top of that, a class is a great place to store procedures that you want to be able to execute multiple times.', 'start': 227.89, 'duration': 5.522}, {'end': 237.593, 'text': "You're going to be able to store multiple commands in a class to use over and over.", 'start': 233.632, 'duration': 3.961}, {'end': 244.783, 'text': "And on top of that, like I said before, most of the time you're going to implement undo procedures so that you can undo previous commands.", 'start': 237.893, 'duration': 6.89}, {'end': 251.432, 'text': 'The only negative with the command design pattern is that you need to create many small classes to store lists of these commands.', 'start': 245.043, 'duration': 6.389}, {'end': 253.154, 'text': "So that's a basic rundown.", 'start': 251.652, 'duration': 1.502}, {'end': 254.877, 'text': "So let's just jump right into the code.", 'start': 253.214, 'duration': 1.663}, {'end': 255.929, 'text': 'All right.', 'start': 255.629, 'duration': 0.3}], 'summary': 'Command design pattern allows storing and executing multiple commands, but requires creating many small classes.', 'duration': 32.561, 'max_score': 223.368, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7Pj5kAhVBlg/pics/7Pj5kAhVBlg223368.jpg'}, {'end': 343.003, 'src': 'embed', 'start': 314.174, 'weight': 2, 'content': [{'end': 315.934, 'text': "So here's television.java.", 'start': 314.174, 'duration': 1.76}, {'end': 319.516, 'text': "We're just going to go public class television.", 'start': 316.134, 'duration': 3.382}, {'end': 326.319, 'text': "And I know I say it all the time, but really, at least for myself, I wasn't able to completely understand this pattern until I saw it in print.", 'start': 319.756, 'duration': 6.563}, {'end': 329.452, 'text': 'So of course I provide you that option underneath this video.', 'start': 326.71, 'duration': 2.742}, {'end': 338.119, 'text': "Okay, so just going to implement that electronic device and then we're gonna come in here and Eclipse is gonna allow us to add unimplemented methods,", 'start': 329.853, 'duration': 8.266}, {'end': 339.62, 'text': "so I don't have to type all that stuff out.", 'start': 338.119, 'duration': 1.501}, {'end': 343.003, 'text': "And then inside of here I'm gonna create myself a private method.", 'start': 339.82, 'duration': 3.183}], 'summary': 'A demonstration of implementing a television class in java using eclipse.', 'duration': 28.829, 'max_score': 314.174, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7Pj5kAhVBlg/pics/7Pj5kAhVBlg314174.jpg'}], 'start': 223.368, 'title': 'Command design pattern and creating a television receiver', 'summary': 'Explains the command design pattern, its advantages of storing multiple commands in a class and implementing undo procedures, and its disadvantage of needing to create many small classes. it also covers creating a television receiver in java, demonstrating the implementation of the command pattern with specific commands and an interface, and explaining the execution process, providing a practical understanding of the pattern and its usage.', 'chapters': [{'end': 291.312, 'start': 223.368, 'title': 'Command design pattern', 'summary': 'Explains the command design pattern, its advantages like storing multiple commands in a class and implementing undo procedures, and its disadvantage of needing to create many small classes to store lists of commands.', 'duration': 67.944, 'highlights': ['The command design pattern allows storing a list of commands for later use and executing procedures multiple times, creating the ability to store multiple commands in a class to use repeatedly.', 'Implementing undo procedures is common with the command design pattern to undo previous commands, and it involves creating many small classes to store lists of these commands.']}, {'end': 501.484, 'start': 291.912, 'title': 'Creating a television receiver', 'summary': 'Covers creating a television receiver in java, demonstrating the implementation of the command pattern with specific commands and an interface, and explaining the execution process, providing a practical understanding of the pattern and its usage.', 'duration': 209.572, 'highlights': ['The chapter covers creating a television receiver in Java The transcript discusses the creation of a television receiver in Java, demonstrating the implementation of the command pattern.', 'Demonstrating the implementation of the command pattern The transcript provides a practical demonstration of implementing the command pattern in Java, showcasing the use of specific commands and an interface.', 'Explaining the execution process The transcript explains the execution process of the command pattern, emphasizing the practical understanding and usage of the pattern.']}], 'duration': 278.116, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7Pj5kAhVBlg/pics/7Pj5kAhVBlg223368.jpg', 'highlights': ['The command design pattern allows storing a list of commands for later use and executing procedures multiple times, creating the ability to store multiple commands in a class to use repeatedly.', 'Implementing undo procedures is common with the command design pattern to undo previous commands, and it involves creating many small classes to store lists of these commands.', 'The chapter covers creating a television receiver in Java The transcript discusses the creation of a television receiver in Java, demonstrating the implementation of the command pattern.', 'Demonstrating the implementation of the command pattern The transcript provides a practical demonstration of implementing the command pattern in Java, showcasing the use of specific commands and an interface.', 'Explaining the execution process The transcript explains the execution process of the command pattern, emphasizing the practical understanding and usage of the pattern.']}, {'end': 740.536, 'segs': [{'end': 537.58, 'src': 'embed', 'start': 501.864, 'weight': 3, 'content': [{'end': 508.327, 'text': 'turn TV off dot Java, click on that paste inside of their turn TV off is going to be the name for that.', 'start': 501.864, 'duration': 6.463}, {'end': 512.849, 'text': "And then we're just going to come through here and make a couple little changes, but pretty simple stuff.", 'start': 508.727, 'duration': 4.122}, {'end': 514.75, 'text': "Just about everything's already done there.", 'start': 513.49, 'duration': 1.26}, {'end': 520.493, 'text': "And then down here, since it's the turn TV off, we're going to call the off method on the device.", 'start': 515.03, 'duration': 5.463}, {'end': 523.955, 'text': "And in case you forgot, let's just go over to television dot Java.", 'start': 520.893, 'duration': 3.062}, {'end': 527.957, 'text': "See, all it's doing is coming here and calling these very specific methods.", 'start': 524.195, 'duration': 3.762}, {'end': 530.358, 'text': 'for these very specific objects.', 'start': 528.317, 'duration': 2.041}, {'end': 531.478, 'text': 'So no big deal.', 'start': 530.758, 'duration': 0.72}, {'end': 535.219, 'text': "So let's get back to turn TV off dot Java and look at it again.", 'start': 531.758, 'duration': 3.461}, {'end': 536.04, 'text': "And that's it.", 'start': 535.539, 'duration': 0.501}, {'end': 536.64, 'text': "You're done.", 'start': 536.2, 'duration': 0.44}, {'end': 537.58, 'text': 'We just did that.', 'start': 536.8, 'duration': 0.78}], 'summary': 'Turning off tv by calling off method on device in java.', 'duration': 35.716, 'max_score': 501.864, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7Pj5kAhVBlg/pics/7Pj5kAhVBlg501864.jpg'}, {'end': 606.922, 'src': 'heatmap', 'start': 575.347, 'weight': 0, 'content': [{'end': 576.748, 'text': 'And it is going to have a method.', 'start': 575.347, 'duration': 1.401}, {'end': 582.651, 'text': "First off, its name is going to be deviceButton because we're using sort of like a remote sort of thing here.", 'start': 577.108, 'duration': 5.543}, {'end': 587.114, 'text': "So we're going to come inside of this and it's going to have a method called press that, when executed,", 'start': 582.852, 'duration': 4.262}, {'end': 590.076, 'text': 'is going to cause the execute method to be called.', 'start': 587.114, 'duration': 2.962}, {'end': 596.158, 'text': 'And then, of course, the execute method for the command interface then calls the method assigned in the class that implements the command interface.', 'start': 590.436, 'duration': 5.722}, {'end': 600.359, 'text': 'So just go public class device button.', 'start': 596.938, 'duration': 3.421}, {'end': 601.44, 'text': 'There that is.', 'start': 600.84, 'duration': 0.6}, {'end': 606.922, 'text': "And then it's going to be passed command, of course, in a generic sort of format.", 'start': 601.88, 'duration': 5.042}], 'summary': "The devicebutton method 'press' triggers the execute method, calling the assigned method in the implementing class.", 'duration': 31.575, 'max_score': 575.347, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7Pj5kAhVBlg/pics/7Pj5kAhVBlg575347.jpg'}, {'end': 685.372, 'src': 'heatmap', 'start': 614.904, 'weight': 1, 'content': [{'end': 619.786, 'text': "And I'm just going to go the command, just like I always do, is equal to new command.", 'start': 614.904, 'duration': 4.882}, {'end': 624.909, 'text': "And then we're going to create public press that I've been talking about so much.", 'start': 620.206, 'duration': 4.703}, {'end': 627.07, 'text': 'Very, very complicated method.', 'start': 625.489, 'duration': 1.581}, {'end': 633.393, 'text': "What's it going to do? It's going to say the command I want you to run execute, just like we said before.", 'start': 627.37, 'duration': 6.023}, {'end': 641.137, 'text': "And then it's going to worry about command and all of the different objects that are implementing the command interface are then going to just execute that,", 'start': 633.593, 'duration': 7.544}, {'end': 641.898, 'text': 'execute command.', 'start': 641.137, 'duration': 0.761}, {'end': 643.398, 'text': "Again, let's click on command.", 'start': 642.138, 'duration': 1.26}, {'end': 646.26, 'text': "What's it do? Forces all commands to have an execute method.", 'start': 643.438, 'duration': 2.822}, {'end': 647.61, 'text': "Here's turn TV on.", 'start': 646.51, 'duration': 1.1}, {'end': 648.471, 'text': 'There it does.', 'start': 647.831, 'duration': 0.64}, {'end': 654.733, 'text': 'Whenever execute is going to be called on this method, it instead calls another method for our device.', 'start': 648.691, 'duration': 6.042}, {'end': 658.135, 'text': "And where is our device? Well, here's television.java.", 'start': 655.314, 'duration': 2.821}, {'end': 658.895, 'text': 'There it is.', 'start': 658.315, 'duration': 0.58}, {'end': 660.516, 'text': 'You just have to wrap your head around it.', 'start': 658.915, 'duration': 1.601}, {'end': 663.017, 'text': "Just look at it from a couple different directions, and you'll get it.", 'start': 660.536, 'duration': 2.481}, {'end': 665.118, 'text': "So let's get back into device button.", 'start': 663.037, 'duration': 2.081}, {'end': 667.659, 'text': "And yes, indeed, it's done as well.", 'start': 665.698, 'duration': 1.961}, {'end': 673.103, 'text': "So then what do we need to do? Well, we're going to have to create something else called TVRemote.java.", 'start': 667.979, 'duration': 5.124}, {'end': 679.487, 'text': "And in essence, what TVRemote.java is going to do is it's going to return the type of device that we're going to use.", 'start': 673.523, 'duration': 5.964}, {'end': 685.372, 'text': 'Now I chose to keep this fairly simple, but of course you could have it work with multiple different devices,', 'start': 679.909, 'duration': 5.463}], 'summary': 'Creating a new command interface to execute different objects and methods for device control.', 'duration': 70.468, 'max_score': 614.904, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7Pj5kAhVBlg/pics/7Pj5kAhVBlg614904.jpg'}, {'end': 673.103, 'src': 'embed', 'start': 648.691, 'weight': 2, 'content': [{'end': 654.733, 'text': 'Whenever execute is going to be called on this method, it instead calls another method for our device.', 'start': 648.691, 'duration': 6.042}, {'end': 658.135, 'text': "And where is our device? Well, here's television.java.", 'start': 655.314, 'duration': 2.821}, {'end': 658.895, 'text': 'There it is.', 'start': 658.315, 'duration': 0.58}, {'end': 660.516, 'text': 'You just have to wrap your head around it.', 'start': 658.915, 'duration': 1.601}, {'end': 663.017, 'text': "Just look at it from a couple different directions, and you'll get it.", 'start': 660.536, 'duration': 2.481}, {'end': 665.118, 'text': "So let's get back into device button.", 'start': 663.037, 'duration': 2.081}, {'end': 667.659, 'text': "And yes, indeed, it's done as well.", 'start': 665.698, 'duration': 1.961}, {'end': 673.103, 'text': "So then what do we need to do? Well, we're going to have to create something else called TVRemote.java.", 'start': 667.979, 'duration': 5.124}], 'summary': 'Method execute is replaced, device location in television.java, creation of tvremote.java.', 'duration': 24.412, 'max_score': 648.691, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7Pj5kAhVBlg/pics/7Pj5kAhVBlg648691.jpg'}, {'end': 729.166, 'src': 'heatmap', 'start': 695.979, 'weight': 0.865, 'content': [{'end': 703.023, 'text': "Okay, so it's going to have this static method inside of it, and in this situation it's just going to return a new television.", 'start': 695.979, 'duration': 7.044}, {'end': 710.206, 'text': "which is just going to say, hey, we're just going to be using a television object here as our receiver to handle everything.", 'start': 703.379, 'duration': 6.827}, {'end': 711.268, 'text': "So that's pretty simple.", 'start': 710.367, 'duration': 0.901}, {'end': 717.935, 'text': "So now we're going to go into play with remote.java, and this is the actual application, and it's going to actually create all this stuff.", 'start': 711.628, 'duration': 6.307}, {'end': 719.497, 'text': 'So I need a couple different things here.', 'start': 718.115, 'duration': 1.382}, {'end': 726.824, 'text': "I'm going to go java.util array list and then I'm also going to use a basic list.", 'start': 719.517, 'duration': 7.307}, {'end': 729.166, 'text': 'so just chop off the array part and there you go.', 'start': 726.824, 'duration': 2.342}], 'summary': 'A static method returning a new television; using java.util arraylist and basic list in the application.', 'duration': 33.187, 'max_score': 695.979, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7Pj5kAhVBlg/pics/7Pj5kAhVBlg695979.jpg'}], 'start': 501.864, 'title': 'Implementing turn tv off functionality and command design pattern implementation', 'summary': 'Demonstrates the implementation of turn tv off functionality in the turn tv off java file and discusses the implementation of the command design pattern in java, focusing on specific methods for specific objects and the creation of classes to handle device commands and the application of the pattern to control electronic devices, with a focus on creating an invoker class and its method for executing commands.', 'chapters': [{'end': 537.58, 'start': 501.864, 'title': 'Implementing turn tv off functionality', 'summary': 'Demonstrates the implementation of the turn tv off functionality by making changes in the turn tv off java file and calling the off method on the device, referencing specific methods for specific objects.', 'duration': 35.716, 'highlights': ['Implemented turn TV off functionality by making changes in the turn TV off Java file and calling the off method on the device.', 'Referenced specific methods for specific objects in the television dot Java file.']}, {'end': 740.536, 'start': 537.84, 'title': 'Command design pattern implementation', 'summary': 'Discusses the implementation of the command design pattern in java, covering the creation of classes to handle device commands and the application of the pattern to control electronic devices, with a focus on creating an invoker class and its method for executing commands.', 'duration': 202.696, 'highlights': ["Creation of DeviceButton class to act as an invoker for commands The creation of the DeviceButton class is pivotal, as it acts as the invoker for commands, with a method 'press' that executes the command's 'execute' method, providing a central mechanism for triggering various device commands.", 'Utilization of Command interface and implementing classes to control device actions The usage of the Command interface and its implementing classes enables the control of device actions, with the execute method ensuring that all commands have a consistent execution process, exemplified by the turn TV on command.', "Implementation of TVRemote class to handle device type selection The implementation of the TVRemote class facilitates device type selection through a static method 'getDevice', offering flexibility for using different electronic devices, as demonstrated by returning a new television object for command execution."]}], 'duration': 238.672, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7Pj5kAhVBlg/pics/7Pj5kAhVBlg501864.jpg', 'highlights': ["Creation of DeviceButton class to act as an invoker for commands The creation of the DeviceButton class is pivotal, as it acts as the invoker for commands, with a method 'press' that executes the command's 'execute' method, providing a central mechanism for triggering various device commands.", 'Utilization of Command interface and implementing classes to control device actions The usage of the Command interface and its implementing classes enables the control of device actions, with the execute method ensuring that all commands have a consistent execution process, exemplified by the turn TV on command.', "Implementation of TVRemote class to handle device type selection The implementation of the TVRemote class facilitates device type selection through a static method 'getDevice', offering flexibility for using different electronic devices, as demonstrated by returning a new television object for command execution.", 'Implemented turn TV off functionality by making changes in the turn TV off Java file and calling the off method on the device.', 'Referenced specific methods for specific objects in the television dot Java file.']}, {'end': 952.718, 'segs': [{'end': 767.818, 'src': 'embed', 'start': 741.021, 'weight': 0, 'content': [{'end': 745.084, 'text': 'Then we want to get the electronic device that we want to use.', 'start': 741.021, 'duration': 4.063}, {'end': 751.948, 'text': "And we're just going to go new device is equal to TV remote dot get device.", 'start': 745.744, 'duration': 6.204}, {'end': 755.51, 'text': "And what is that going to do for me? Let's just take a look.", 'start': 752.528, 'duration': 2.982}, {'end': 756.451, 'text': "Here's TV remote.", 'start': 755.57, 'duration': 0.881}, {'end': 757.712, 'text': "It's going to return a television.", 'start': 756.571, 'duration': 1.141}, {'end': 761.794, 'text': "So it's going to say, hey, you want a device? Well, you're going to work with television.", 'start': 757.892, 'duration': 3.902}, {'end': 765.877, 'text': 'Now, of course, we could figure out different ways to come in here and use all the other different devices.', 'start': 761.834, 'duration': 4.043}, {'end': 767.818, 'text': "And in fact, I'm going to show you another different way to do that.", 'start': 765.917, 'duration': 1.901}], 'summary': 'Demonstrating code to retrieve electronic devices, focusing on tv remote and television.', 'duration': 26.797, 'max_score': 741.021, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7Pj5kAhVBlg/pics/7Pj5kAhVBlg741021.jpg'}, {'end': 919.801, 'src': 'embed', 'start': 892.844, 'weight': 2, 'content': [{'end': 895.946, 'text': "We're going to lop this off of here, because we already defined it.", 'start': 892.844, 'duration': 3.102}, {'end': 900.109, 'text': "And here we're going to pass the off command, which we just created.", 'start': 896.286, 'duration': 3.823}, {'end': 904.852, 'text': "And here, onPress doesn't care what type of command you're sending, it's going to work either way.", 'start': 900.509, 'duration': 4.343}, {'end': 906.073, 'text': "So let's execute that.", 'start': 905.073, 'duration': 1}, {'end': 909.336, 'text': 'And you can see I turned the TV on, and then I turned the television off.', 'start': 906.314, 'duration': 3.022}, {'end': 914.098, 'text': "so let's see what happens whenever we come in here and start playing around with the volume.", 'start': 909.836, 'duration': 4.262}, {'end': 918.88, 'text': 'and even better, can we call press multiple times without things flipping out?', 'start': 914.098, 'duration': 4.782}, {'end': 919.801, 'text': 'yes, we can.', 'start': 918.88, 'duration': 0.921}], 'summary': 'Demonstrating the functionality of controlling a tv using commands, including turning it on and off and adjusting the volume, successfully executing multiple commands.', 'duration': 26.957, 'max_score': 892.844, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7Pj5kAhVBlg/pics/7Pj5kAhVBlg892844.jpg'}], 'start': 741.021, 'title': 'Device control with commands', 'summary': 'Covers using commands to control electronic devices, such as creating a new device, defining commands, and executing actions, with a focus on using a tv remote as an example. it also explains how to implement generic commands to control devices, including turning the tv on and off and adjusting the volume, demonstrating the simplicity and flexibility of the process.', 'chapters': [{'end': 835.472, 'start': 741.021, 'title': 'Understanding device control with commands', 'summary': 'Covers the concept of using commands to control electronic devices, such as creating a new device, defining commands, and executing actions, with a focus on using a tv remote as an example.', 'duration': 94.451, 'highlights': ['The chapter demonstrates creating a new device and defining commands, such as turning the TV on, to control electronic devices, providing a foundational understanding of using commands for device control.', 'The concept of a receiver, represented by the device button, is introduced to perform actions when called, enhancing the understanding of the command pattern for device control.', 'The chapter emphasizes the execution of specific methods within the electronic device, such as turning on the TV, highlighting the practical application of commands for controlling electronic devices.']}, {'end': 952.718, 'start': 835.885, 'title': 'Implementing generic commands for controlling devices', 'summary': 'Explains how to implement generic commands to control devices, including turning the tv on and off and adjusting the volume, demonstrating the simplicity and flexibility of the process.', 'duration': 116.833, 'highlights': ['The process of implementing generic commands to control devices is demonstrated, including turning the TV on and off and adjusting the volume, showcasing the simplicity and flexibility of the process.', 'Executing the commands successfully demonstrates the effectiveness of the implemented generic commands, such as turning the TV on and off and increasing the volume, providing tangible evidence of their functionality and reliability.', 'The demonstration of calling press multiple times without issues provides practical evidence of the stability and robustness of the implemented generic commands, increasing confidence in their reliability and effectiveness.', 'The step-by-step process of creating and executing specific commands, such as turning the TV on and off and adjusting the volume, provides a clear and detailed guide for implementing generic commands to control devices.']}], 'duration': 211.697, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7Pj5kAhVBlg/pics/7Pj5kAhVBlg741021.jpg', 'highlights': ['The chapter demonstrates creating a new device and defining commands, providing a foundational understanding of using commands for device control.', 'The process of implementing generic commands to control devices is demonstrated, showcasing the simplicity and flexibility of the process.', 'The demonstration of calling press multiple times without issues provides practical evidence of the stability and robustness of the implemented generic commands.']}, {'end': 1419.731, 'segs': [{'end': 980.733, 'src': 'embed', 'start': 952.958, 'weight': 2, 'content': [{'end': 955.599, 'text': 'So pretty cool, really implementing a remote control here.', 'start': 952.958, 'duration': 2.641}, {'end': 960.961, 'text': "So now let's throw another device into the mix, just to show you how simple that is to work with.", 'start': 955.899, 'duration': 5.062}, {'end': 966.484, 'text': "We don't have to touch electronic device in any way, as long as we don't need to have any other methods implemented.", 'start': 961.202, 'duration': 5.282}, {'end': 970.006, 'text': "Let's say we want to have radio.java created.", 'start': 967.044, 'duration': 2.962}, {'end': 977.151, 'text': "How hard is that? Well, we're going to go public class radio implements electronic device.", 'start': 970.086, 'duration': 7.065}, {'end': 980.733, 'text': "And just to save ourselves some time, I'm going to jump inside of here.", 'start': 977.711, 'duration': 3.022}], 'summary': 'Demonstrating remote control implementation and adding a new device easily.', 'duration': 27.775, 'max_score': 952.958, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7Pj5kAhVBlg/pics/7Pj5kAhVBlg952958.jpg'}, {'end': 1090.466, 'src': 'embed', 'start': 1060.291, 'weight': 0, 'content': [{'end': 1061.732, 'text': 'So paste that inside of there.', 'start': 1060.291, 'duration': 1.441}, {'end': 1064.454, 'text': "And here I'm going to say new devices, like that.", 'start': 1062.032, 'duration': 2.422}, {'end': 1070.619, 'text': 'And then to transfer all of these devices that I now want to control in one fell swoop.', 'start': 1065.009, 'duration': 5.61}, {'end': 1075.608, 'text': "I'm going to take the new devices list that's going to be sent to me and I'm going to save it to my own personalized list.", 'start': 1070.619, 'duration': 4.989}, {'end': 1077.936, 'text': 'All right, now we get to execute.', 'start': 1076.035, 'duration': 1.901}, {'end': 1083.441, 'text': "And what we're going to do here with execute is we're going to shut all of them off using an enhanced for loop.", 'start': 1078.057, 'duration': 5.384}, {'end': 1086.163, 'text': 'So they are all electronic devices.', 'start': 1083.701, 'duration': 2.462}, {'end': 1087.424, 'text': "So that's cool.", 'start': 1086.723, 'duration': 0.701}, {'end': 1090.466, 'text': "And we're going to say device individually.", 'start': 1087.924, 'duration': 2.542}], 'summary': 'Transferring and controlling new devices, then shutting all off using for loop.', 'duration': 30.175, 'max_score': 1060.291, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7Pj5kAhVBlg/pics/7Pj5kAhVBlg1060291.jpg'}, {'end': 1142.699, 'src': 'embed', 'start': 1117.645, 'weight': 3, 'content': [{'end': 1122.921, 'text': 'Alright, so we need to create ourselves a whole bunch of different devices we want to work with.', 'start': 1117.645, 'duration': 5.276}, {'end': 1129.348, 'text': "So I'm just going to go and create a new television and I'm just going to call it the TV is equal to television.", 'start': 1122.982, 'duration': 6.366}, {'end': 1131.269, 'text': "It's a fun tutorial to do.", 'start': 1129.368, 'duration': 1.901}, {'end': 1132.851, 'text': "And then I'm going to do radio.", 'start': 1131.55, 'duration': 1.301}, {'end': 1137.215, 'text': 'The radio is equal to new and it is a radio object.', 'start': 1133.331, 'duration': 3.884}, {'end': 1142.699, 'text': "Then I need to create myself a list, and it's going to be electronic device.", 'start': 1137.395, 'duration': 5.304}], 'summary': 'Creating various electronic devices like tv and radio in a tutorial.', 'duration': 25.054, 'max_score': 1117.645, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7Pj5kAhVBlg/pics/7Pj5kAhVBlg1117645.jpg'}, {'end': 1249.75, 'src': 'embed', 'start': 1222.793, 'weight': 1, 'content': [{'end': 1227.055, 'text': "I'm going to do this to a certain extent and I'm going to leave part of it for you to do as homework.", 'start': 1222.793, 'duration': 4.262}, {'end': 1230.996, 'text': 'But either way, it is common to be able to undo commands using a command pattern.', 'start': 1227.255, 'duration': 3.741}, {'end': 1234.638, 'text': "It's not required, but it's just something that is very common that you will see.", 'start': 1231.016, 'duration': 3.622}, {'end': 1242.384, 'text': 'And to do so, the device button will have a method called undo, which will perform the opposite action or whatever the normal command performs.', 'start': 1234.978, 'duration': 7.406}, {'end': 1248.329, 'text': "And to implement undo, you're just going to need to add it to every single class in which you have the execute method.", 'start': 1242.684, 'duration': 5.645}, {'end': 1249.75, 'text': 'So what are we going to need to do here?', 'start': 1248.489, 'duration': 1.261}], 'summary': 'Common to undo commands using command pattern, adding undo to every class with execute method.', 'duration': 26.957, 'max_score': 1222.793, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7Pj5kAhVBlg/pics/7Pj5kAhVBlg1222793.jpg'}], 'start': 952.958, 'title': 'Implementing remote control and command pattern for devices', 'summary': 'Demonstrates how to implement a remote control for electronic devices, including creating a radio class, implementing a master off switch to turn all devices off at once, and executing the shutdown of all devices. it also shows the implementation of the command pattern for electronic devices, such as tv and radio, allowing the control of multiple devices and the addition of an undo feature.', 'chapters': [{'end': 1117.625, 'start': 952.958, 'title': 'Implementing remote control', 'summary': 'Demonstrates how to implement a remote control for electronic devices, including creating a radio class, implementing a master off switch to turn all devices off at once, and executing the shutdown of all devices using an enhanced for loop.', 'duration': 164.667, 'highlights': ['The chapter demonstrates how to implement a remote control for electronic devices, including creating a radio class, implementing a master off switch to turn all devices off at once, and executing the shutdown of all devices using an enhanced for loop.', 'Creating a radio class involves implementing the electronic device interface and defining its functionalities, such as volume control.', 'Implementing a master off switch class, TurnItAllOff, using a list to shut off all electronic devices at once, showcasing the use of the command pattern.', 'The execute method in TurnItAllOff class utilizes an enhanced for loop to turn off each electronic device individually, providing a convenient way to control multiple devices simultaneously.']}, {'end': 1419.731, 'start': 1117.645, 'title': 'Implementing command pattern for devices', 'summary': 'Demonstrates the implementation of the command pattern for electronic devices, such as tv and radio, allowing the control of multiple devices and the addition of an undo feature.', 'duration': 302.086, 'highlights': ["The chapter demonstrates the creation and addition of electronic devices, such as TV and radio, to a list, allowing for centralized control. The speaker creates a list 'all devices' and adds the TV and radio to it, enabling centralized control of the devices.", "The implementation of the command pattern allows the execution and undoing of commands for electronic devices. The speaker demonstrates the addition of an 'undo' method to the device button, enabling the undoing of commands for electronic devices using the command pattern.", 'The chapter provides guidance on implementing undo functionality for commands using linked lists. The speaker advises on using linked lists to implement the undo functionality for commands, enabling the reversal of commands in a systematic manner.']}], 'duration': 466.773, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7Pj5kAhVBlg/pics/7Pj5kAhVBlg952958.jpg', 'highlights': ['The chapter demonstrates how to implement a remote control for electronic devices, including creating a radio class, implementing a master off switch to turn all devices off at once, and executing the shutdown of all devices using an enhanced for loop.', "The implementation of the command pattern allows the execution and undoing of commands for electronic devices. The speaker demonstrates the addition of an 'undo' method to the device button, enabling the undoing of commands for electronic devices using the command pattern.", 'Creating a radio class involves implementing the electronic device interface and defining its functionalities, such as volume control.', "The chapter demonstrates the creation and addition of electronic devices, such as TV and radio, to a list, allowing for centralized control. The speaker creates a list 'all devices' and adds the TV and radio to it, enabling centralized control of the devices."]}], 'highlights': ['The tutorial guarantees a full understanding of the command design pattern by going through all the provided steps.', 'The code for the design pattern is available underneath the video, ensuring comprehensive understanding.', 'The chapter covers the command design pattern in numerous different ways, including simple definition, walkthrough using words, UML diagram, and all of the code.', 'The capability for undoing commands is a key feature of the command design pattern. The pattern provides the capability to undo commands, enhancing its flexibility and usefulness in certain scenarios.', 'The transfer of commands from an invoker to a receiver is a fundamental aspect of the command design pattern. The pattern involves the invocation of a command by the client, which is then transferred to an object called the receiver for execution.', 'The command design pattern is used to encapsulate method calls, allowing for execution at a later time. The pattern allows for the storage of lists of codes that are executed at a later time or multiple times.', 'The command design pattern allows storing a list of commands for later use and executing procedures multiple times, creating the ability to store multiple commands in a class to use repeatedly.', 'Implementing undo procedures is common with the command design pattern to undo previous commands, and it involves creating many small classes to store lists of these commands.', 'The chapter covers creating a television receiver in Java The transcript discusses the creation of a television receiver in Java, demonstrating the implementation of the command pattern.', 'Demonstrating the implementation of the command pattern The transcript provides a practical demonstration of implementing the command pattern in Java, showcasing the use of specific commands and an interface.', 'Explaining the execution process The transcript explains the execution process of the command pattern, emphasizing the practical understanding and usage of the pattern.', "Creation of DeviceButton class to act as an invoker for commands The creation of the DeviceButton class is pivotal, as it acts as the invoker for commands, with a method 'press' that executes the command's 'execute' method, providing a central mechanism for triggering various device commands.", 'Utilization of Command interface and implementing classes to control device actions The usage of the Command interface and its implementing classes enables the control of device actions, with the execute method ensuring that all commands have a consistent execution process, exemplified by the turn TV on command.', "Implementation of TVRemote class to handle device type selection The implementation of the TVRemote class facilitates device type selection through a static method 'getDevice', offering flexibility for using different electronic devices, as demonstrated by returning a new television object for command execution.", 'Implemented turn TV off functionality by making changes in the turn TV off Java file and calling the off method on the device.', 'Referenced specific methods for specific objects in the television dot Java file.', 'The chapter demonstrates creating a new device and defining commands, providing a foundational understanding of using commands for device control.', 'The process of implementing generic commands to control devices is demonstrated, showcasing the simplicity and flexibility of the process.', 'The demonstration of calling press multiple times without issues provides practical evidence of the stability and robustness of the implemented generic commands.', 'The chapter demonstrates how to implement a remote control for electronic devices, including creating a radio class, implementing a master off switch to turn all devices off at once, and executing the shutdown of all devices using an enhanced for loop.', "The implementation of the command pattern allows the execution and undoing of commands for electronic devices. The speaker demonstrates the addition of an 'undo' method to the device button, enabling the undoing of commands for electronic devices using the command pattern.", 'Creating a radio class involves implementing the electronic device interface and defining its functionalities, such as volume control.', "The chapter demonstrates the creation and addition of electronic devices, such as TV and radio, to a list, allowing for centralized control. The speaker creates a list 'all devices' and adds the TV and radio to it, enabling centralized control of the devices."]}