No video

The Command Pattern Explained and Implemented in Java | Behavioral Design Patterns | Geekific

  Рет қаралды 58,437

Geekific

Geekific

Күн бұрын

Пікірлер: 42
@carlosalejandromeliscurbel2679
@carlosalejandromeliscurbel2679 Жыл бұрын
Great job. I can say I'm learning more with your videos than going to class. In 7 minutes you accomplished what my teacher tried in 45minutes😂
@seranvishwa8714
@seranvishwa8714 7 ай бұрын
Same in my case😂
@lucasrubio7664
@lucasrubio7664 Жыл бұрын
I've been watching some of your Design Patterns videos for a uni exam. Great explanations with really good visual examples. They are very helpful thank you!!
@babelwebdeveloper2240
@babelwebdeveloper2240 2 жыл бұрын
Awesome work! Such content is very necessary, don't stop doing what you do!
@geekific
@geekific 2 жыл бұрын
Thanks a lot, glad you like it, will do!
@AnkitPandey-ft8jb
@AnkitPandey-ft8jb Жыл бұрын
Your explanations are most relevant and spot on! Gives the gist of every pattern in very little time. Thanks for doing this.
@charlesopuoro5295
@charlesopuoro5295 9 ай бұрын
Thanks always for these insightful, scenario-based videos that help us grasp these Software Design Patterns.
@GreyDeathVaccine
@GreyDeathVaccine 2 жыл бұрын
You have earned a sub with down to Earth example 🙂
@geekific
@geekific 2 жыл бұрын
Thank you for the support :)
@Hermioneswand1
@Hermioneswand1 2 жыл бұрын
Wonderfully explained, thanks! Going to explore all your other videos!! Keep going. Thank you
@geekific
@geekific 2 жыл бұрын
Awesome, thanks for the support!
@elvenpath7
@elvenpath7 Жыл бұрын
Geekific, thanks for what you are doing ! You videos are so cool.
@lelo8244
@lelo8244 2 жыл бұрын
Literally the best! Tysm
@geekific
@geekific 2 жыл бұрын
Glad it helped :)
@LordErnie
@LordErnie 9 ай бұрын
I'm sorry to say that the command pattern, like many other OO patterns, is just one prime example of how OO fcks itself by not treating functions as assignable values. What is a command? It's one hell of a weird way to define a function abstraction. Here is this thing that will call a function if you poke it. Oh yea the function can change, and the thing you are poaking abstracts away what the concrete function is. "But commands are objects that can have state and yayayayayyayadaydadada". Yes, but when you just look at the invoke function in is a function that does something before, maybe during, and after a dynamic function call. You might as well just have a wrapper function composed with a predefined state context. Is this hard? No. Is it just a fancy way of making a function return a function, and calling that function? Yes. Bohooo a returns b composed with parameter c from a. Call b, and it does the spookies. I do see how the command pattern has its usages, but it's an ugly way of saying that you can't pass functions as values, and that you can't produce them either. It's a fckd wrapper. But nice vid tho very informative, keep it up ♥
@SumTingWong886
@SumTingWong886 8 ай бұрын
Yeah I’m not reading all that, but I’m happy for you or sorry that happened.
@shankar7435
@shankar7435 7 ай бұрын
Thanks for such insights to know what I am getting into.
@parinjasoliya7836
@parinjasoliya7836 11 ай бұрын
Very Good explanation!
@Maik55732
@Maik55732 Жыл бұрын
First of all, thank you for the explanation, it was all well presented. However, I still have few questions: 1. I don't see how the code prior the pattern is that much coupled. Could please point out some dependencies or changes that could be made on the Light class that would lead to crash in the subclasses? 2. It's not clear for me where I can use this pattern. Any system where I have a command? Perhaps it was too much to ask, but if anyone can help me out with this, I'd be much appreciated.
@geekific
@geekific Жыл бұрын
Hello! Glad you liked it! 1- In the first implementation, everytime you add stuff to your Room (like Lights) all subclasses are affected, and as the list of attributes added grow, these Rooms will be handling many responsibilities. In addition to this they are aware of these functionalities. When we used the command, this became generic, the Rooms are not aware anymore of what is being executed, just that it can execute something, and all the code related to Lights for example is now encapsulated in its own class (this is explained from 2:50 to 4:00 if you want to check it out again) 2- The command pattern decouples the classes that invoke the operation from the object that knows how to execute the operation. One use-case for using this pattern is that the executor of the command doesn't need to know anything about what the command is executing, what attributes it needs or what it actually does, as that is encapsulated in the command. This allows you to have a list of commands that are executed in order for example, that are dependent on other items without being dependent on the executor, that are triggered based on a certain event... Hope this helps! Cheers!
@mrjessan2343
@mrjessan2343 7 ай бұрын
Thank you for the video but in 4:35 uml diagram you draw the arrow to invoker from client. But in the other resources there is no connections between them. Is it mistake or what?
@yairlevi8469
@yairlevi8469 Жыл бұрын
Amazing content
@harshmalra3085
@harshmalra3085 2 жыл бұрын
best content.
@geekific
@geekific 2 жыл бұрын
So glad you are enjoying our videos :)
@TheClockmister
@TheClockmister 3 ай бұрын
everyone gangsta until sander death stares you
@genatokarev810
@genatokarev810 Жыл бұрын
Thank you. Love your videos so much. Have a question. How can we know that the LivingRoom's lights are on? I suppose we should have created something like livingRoomLights variable instead of just passing `new Light()` so we could have known that from the client code. Or wrap all of that with another class around the livingRoom and the livingRoomLights objets.
@geekific
@geekific Жыл бұрын
Glad you do! Thank you :) This code is strictly to demonstrate the pattern you can expand on it as you wish.
@davidblbulyan3077
@davidblbulyan3077 10 ай бұрын
3:56 it is strange, because we pass some light in SwitchLightsCommand, but this light, created in the previous line, is not a light of the room
@dee4622
@dee4622 9 ай бұрын
"private Light light" in SwitchLightsCommand is a pointer to Light object not an actual Light object. It doesn't point to any Light object until "new SwitchLightsCommand(new Light())" in the main function. "new" indicates that your dynamically creating the actual object and then that is being passed into the SwitchLightsCommand constructor.
@avegeta1
@avegeta1 6 ай бұрын
I am just wondering, with the command pattern setup, Now Livingroom and Its Light object are not related anymore. How do we tend to preserve the relationship here. To my doubt, I believe we don't have relationships here is because its a kind of a Behavioral pattern and not Creational pattern. Please correct my understanding, I am here to learn.
@geekific
@geekific 6 ай бұрын
Your understanding is on the right track. In the context of the Command Pattern, relationships between objects are not necessarily established through direct associations in the traditional sense. Instead, it promotes a more flexible and loosely coupled structure, where the sender does not need to know the specific class of the receiver. (Maybe the nature of the example here confused you a little). The Command Pattern doesn't explicitly deal with establishing relationships between objects in the way Creational Patterns might, it indirectly influences the interactions between objects by decoupling the sender and receiver.
@sdsd-ec8rw
@sdsd-ec8rw Жыл бұрын
you use classes on slides but in the repository there are stupid records which does not compile because of java version. was that so necessary switching from classes to records and upgrading version of jvm?
@geekific
@geekific Жыл бұрын
Hello! If you are using IntelliJ, you can easily convert from records to classes using the drop down options of the Alt+Enter menu :)
@sdsd-ec8rw
@sdsd-ec8rw Жыл бұрын
@@geekific would have been much better if your slides and your repo were 100% synchronized. Many classes you show on the slides are not even present in the repo. And again, using latest features of the language for rather simple tiny project is not the best choice.
@cparks1000000
@cparks1000000 Жыл бұрын
I think the example is slightly unrealistic as one would unlikely make a class for each room in a house, since the developer has no idea what kind of rooms will be in the user's house. (What if the user has a "sun room" for example or if the "room" is actually an outside space such as a pool area.) I think this is unrealism is a distraction from the core message. It would make more sense for a room to have a name attribute and a list of "things". Alternatively, you could just use a different example. It's also weird that the room has no reference to the objects themselves. For example, there's no way to ask a room if a light is on or off. This information would be essential to making a user-interface phone app. For the curtain example, you might want extra functionality. Perhaps you want the curtains to be 50% open or 33% open. However, this functionality isn't compatible with a (non-dimming) light as on/off is boolean. You can further imagine a light that can change colors. We would now need to pass 2 numbers (hue and saturation) to specify a given color (assuming you want brightness to be independent of color) In general, it seems better to send a command somehow, but I can't see exactly how that would work.
@geekific
@geekific Жыл бұрын
I remember that coming up with an easy example that allows us to focus on the pattern more than the actual use-case was hard here. I hope we were able to relay this information regardless of the messed up use-case xD
@mehdi-vl5nn
@mehdi-vl5nn 11 ай бұрын
Srp be like😮😮😮
@paulchaperon2207
@paulchaperon2207 5 ай бұрын
OOP is a mental asylum
@tommyholmberg
@tommyholmberg Жыл бұрын
I like your presentation but the pattern still makes little sense to me. Looking at the code on time 4:00, you still have the exact same thing as on time 0:55.
@geekific
@geekific Жыл бұрын
Thanks. The difference is that at 0:55 the rooms are aware of lights, however, at 4:00 they are decoupled, you can pass in any type of command you want. And of course they might seem similar, because the idea is not to change the functionality, this has to remain the same, all we want is aim for a cleaner code.
@kennethcarvalho3684
@kennethcarvalho3684 Жыл бұрын
Little bit complicated
@geekific
@geekific Жыл бұрын
Please let us know which parts were the most confusing so we may try to help in the comments :) Cheers!
Command Pattern - Design Patterns (ep 7)
39:12
Christopher Okhravi
Рет қаралды 268 М.
Matching Picture Challenge with Alfredo Larin's family! 👍
00:37
BigSchool
Рет қаралды 36 МЛН
Gli occhiali da sole non mi hanno coperto! 😎
00:13
Senza Limiti
Рет қаралды 20 МЛН
Magic? 😨
00:14
Andrey Grechka
Рет қаралды 19 МЛН
What is the Command Pattern? (Software Design Patterns)
19:55
Be A Better Dev
Рет қаралды 17 М.
How to Program in Unity: Command Pattern Explained
22:37
iHeartGameDev
Рет қаралды 67 М.
10 Design Patterns Explained in 10 Minutes
11:04
Fireship
Рет қаралды 2,2 МЛН
The Flaws of Inheritance
10:01
CodeAesthetic
Рет қаралды 933 М.
Matching Picture Challenge with Alfredo Larin's family! 👍
00:37
BigSchool
Рет қаралды 36 МЛН