In this part of my code refactoring tutorial, I’ll show you how to replace conditionals with the command pattern. I’m also going to do more though.
I’ll also review what the command pattern is. I’ll give an example of when you should use it. We’ll look at how to add flexibility with it. I’ll answer your questions based on the refactoring to patterns book. And, we’ll look at how to store commands in an ArrayList. If you need more look at my Command Design Pattern Tutorial and the code below.
If you like videos like this, it helps to tell Google+ [googleplusone]
Code from the Video
Hello Derek,
Your code refactoring tutorials are amazing. They helped me a lot in understanding the design patterns, and I just wanted to say a big thanks (from me and, probably, almost all my colleagues at Computer Science from UBB University, Romania) – if it wasn’t for your videos I don’t know how I would’ve learned for my exam.
Have a great day,
Adi Ulici
Hello Adi,
Thank you very much for the kind words 🙂 I’m very happy to have helped you and your colleagues. Your country is very beautiful and I’m honored that so many people from Romania seem to like my website.
I’ll do my best to keep making good videos. Thank you for stopping to see my little website
Derek
I have understood Command pattern in this video better than with your design pattern videos. You have also practically answered the question I asked at the end of Command Design Pattern video. Thanks man. You are helpful.
Thank you very much 🙂 I try to do my best
All videos are amazing. When i saw first video, i could’t stop my self to watch further videos. Idea to explain the design patterns is really nice and quite interesting. Small video (duration 10-15 min) and simple coding examples makes all this interesting.
But i am confused in Strategy and Command patterns by seeing the videos. Same kind of “discount calculation” concept is used for both patterns. So can you please make it more clear when to use which one.
Thanks
Thank you very much 🙂 I’m happy that you enjoyed them.
The Strategy Pattern is used to hide the implementation of the solution. Then many different ways to solve a problem can be used with the same interface.
The Command Pattern specializes in creating a specific object that solves a very specific problem all on its own.
I hope that helps