The Command Pattern

  Рет қаралды 1,904

Mateus Guimarães

Mateus Guimarães

Күн бұрын

Пікірлер: 13
Жыл бұрын
Folks - it was brought to my attention I mistakenly passed the Command DTO to the handler's constructor. I somehow didn't notice this while coding and/or recording - my apologies for that. The DTO should be passed to the handler's handle method - the constructor should be used for its dependencies. I'll possibly re-record this video. Thanks for the comment @mnavarrocarter
@mnavarrocarter
@mnavarrocarter Жыл бұрын
I think the command DTO shouldn't be passed in the constructor of the handler. The constructor of the handler should be for its dependencies. The command DTO should be the argument of the handle method. That way, you can reuse the same handler reference (potentially fetched from a container) to handle multiple commands. The way you have it setup now requires to create a brand new handler for every command you want to handle.
@martingrega
@martingrega Жыл бұрын
This.
Жыл бұрын
You're right. I didn't notice until now that I mistakenly passed it in the constructor. Thanks for letting me know - I'll have to re-record this video.
@hhaahh86
@hhaahh86 Жыл бұрын
wow those "Actions" are definitely better than ordinary functions, because of that fancy wrap with "class" and handle method. *going back to write some clojure.*
Жыл бұрын
Have a good one
@TLJAFAR
@TLJAFAR Жыл бұрын
Thanks 👍
@ahirhiten7326
@ahirhiten7326 Жыл бұрын
Which vscode theme is that
@carlosescobar5995
@carlosescobar5995 11 ай бұрын
That's not vscode, it's Phpstorm
@MarlonLCosta
@MarlonLCosta Жыл бұрын
Eu já usava esse pattern mas sem saber, usava como "usecase"
@НазарПанасюк-у8я
@НазарПанасюк-у8я Жыл бұрын
unfortunately, this example doesn't explains to me this pattern. if i have validation and i need to take ONLY validated entries from the request i just do simply as `Post::create($request->validated());` . that's it. the practical usage of the explained pattern is not yet clear to me.
Жыл бұрын
You might be right - in hindsight, this might not have been a good example. Think whenever you have to coordinate different models (models in general, not necessarily eloquent models) and services to achieve certain behavior - think about “purchasing a product”. You’d need to hit a payment gateway, do some validation on your end (is the product in stock? etc.), create several records in the DB - that’s what you could defer to one (or many) commands. Take a look at the Actions a Jetstream application comes with!
@НазарПанасюк-у8я
@НазарПанасюк-у8я Жыл бұрын
@ thanks for the answer. i'll keep this in mind :)
8 Design Patterns | Prime Reacts
22:10
ThePrimeTime
Рет қаралды 425 М.
How to properly integrate with 3rd party providers
16:27
Mateus Guimarães
Рет қаралды 2,1 М.
This mother's baby is too unreliable.
00:13
FUNNY XIAOTING 666
Рет қаралды 39 МЛН
MY HEIGHT vs MrBEAST CREW 🙈📏
00:22
Celine Dept
Рет қаралды 46 МЛН
Стойкость Фёдора поразила всех!
00:58
МИНУС БАЛЛ
Рет қаралды 7 МЛН
What is the Command Pattern? (Software Design Patterns)
19:55
Be A Better Dev
Рет қаралды 17 М.
BEWARE these Laravel attributes | Real World Laravel
19:10
Sam Lewis
Рет қаралды 4,9 М.
The Most Important Design Pattern in React
35:04
Cosden Solutions
Рет қаралды 79 М.
Command Pattern - Design Patterns (ep 7)
39:12
Christopher Okhravi
Рет қаралды 270 М.
Dependency Injection, The Best Pattern
13:16
CodeAesthetic
Рет қаралды 853 М.
PHP-FPM vs Swoole execution model
15:36
Mateus Guimarães
Рет қаралды 6 М.
Command Pattern - Design Patterns
14:49
Web Dev Simplified
Рет қаралды 99 М.
My 10 “Clean” Code Principles (Start These Now)
15:12
Conner Ardman
Рет қаралды 249 М.
Thinking about Aggregates in Active Record
19:22
Mateus Guimarães
Рет қаралды 2,8 М.
This mother's baby is too unreliable.
00:13
FUNNY XIAOTING 666
Рет қаралды 39 МЛН