Command Design Pattern

preview_player
Показать описание


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.
Рекомендации по теме
Комментарии
Автор

Studying for a Software Engineering exam right now, and Design Patterns were explained so horribly. You are a savior!

dennisg.
Автор

As a hobbyist web developer (mechanical engineer), I am loving your design pattern tutorials with realistic examples!! I have been searching tutorials/examples on the internet, including here on YouTube, and have not seen anyone that can be compared to you. Thank you!

crazyingenieur
Автор

The best way I understood this pattern is if you want a set of consistent, predictable behavior, this works well. If you're looking for undo/redo functionality, this is a good option too. So say in like in an e-commerce application, placing an order might involve multiple steps like checking inventory, processing payment, and updating order status. Each step can be a command, and the entire process can be treated as a transaction. Another example could be like in a home automation system, you might want to create a “Good Night” button that turns off all lights, locks doors, and sets the thermostat. Each of these actions can be a command, and the “Good Night” button can execute all these commands in sequence.

The design of the command I thought of like this: Receiver class is the collection of behaviors, say a Light class with methods on() and off(). You'd then create a command class for each method in the receiver class. So all behavior is pooled together and called on a polymorphic execute command. The involker class just takes in commands and calls execute or organizes how to deal with multiple commands or whatever you want to do with it.

krispybutter
Автор

I am a student of Computer Sciences and your video tutorials have really helped me in preparing for my exams. Many thanks...

MuhammadBilal-pisu
Автор

In your PlayWithRemote class, I think it's better form to, instead of using:
  TurnTVOn onCommand = new TurnTVOn(newDevice);
use
  Command onCommand = new TurnTVOn(newDevice);

joeemenaker
Автор

I'm learning Design Patterns with C#. I love the clarity of that video.

EminoMeneko
Автор

Design Patterns are really just guides that an advanced programmer can use to write clean understandable code. They aren't recipes like you are more then likely use to. Once you learn basic syntax you eventually will see that programming is a form of art and you must work to truly master the medium. At this point I don't think there are any real rules except that code should be flexible and understandable. Patterns help you do that.

derekbanas
Автор

I like how this example is also an example for one of the SOLID principles which is the Single Responsibility Principle and that's why I don't think its a negative that you have multiple classes because this reduces the dependency of your code.

ImmunityG
Автор

I really appreciate the teaching style, it's so easy to follow along. Thank you Derek Bananas.

jonacierto
Автор

You're very welcome :) I cover all 24 patterns by the end

derekbanas
Автор

Firstly Thanks and appreciate your effort for us. I think, by this time, you'd have already created all the videos. It would be really helpful if you could explain the problem and then implement the particular design pattern which would make these tutorials stay in our minds forever. Once again Thank you!

connectmkp
Автор

You just showed what hard work does ? Improving others life. You deserve more subs and great respect. ❤❤❤

shankar
Автор

A true technological breakthrough... A TV that can change volume even when it's off!

BobTheZealot
Автор

You could go that route. I have always looked at these patterns as guides rather then as set in stone rules. For the most part though, I followed the GOF rules when I made them in this tutorial

derekbanas
Автор

Hi Derek, great tutorials. Maybe you can add complete class diagrams of the programs you create during the video's.

lanklaan
Автор

Some people don't understand that this is used to solve a problem that is commonly known. If you have not experienced a system that requires this pattern cool, but sooner or later when you start looking for solutions in complex systems you'll find the "patterns" useful instead of reinventing the wheel.

smartwerker
Автор

This entire series is AMAZING! Thank you so much for providing this for free to the world!

adamwhalen
Автор

I love so much about this video. Articulate, confident, prepared, informed, quick, simple. Thank you Derek Banas. I see you're doing pretty well on the Tube and wish you more success in the future.

kelemeno
Автор

Uoooh!!! The TV is turned off, but you can still turn up the volume!! Very powerfull the command pattern, cool!! By the way great tutorials!

Carlomanization
Автор

Don't know what to do without your tutorials! Thank youu

rachelr