Let's talk about one of my favorite patterns: a command bus. I'll give you five reasons why command busses are awesome.
Пікірлер: 32
@kaleucaminha5 ай бұрын
Hey man, I'm here from Brazil, I've been working with PHP code since 2007. Your passion about programming and focus on PHP has been a refresh in my love and motivation for this science and art, Thanks
@metaphoricallyspeaking6 ай бұрын
It's great to hear someone talking so positively about introducing a Command Bus - the benefits are incredible. I'd still use one if I was building a blog, btw! :)
@jean-marcstrauven29906 ай бұрын
Please, make a article or show a exemple..it's really interesting.
@phpannotated6 ай бұрын
I'm drafting a blog post about it as well :)
@batlinАй бұрын
As soon as you described them, I was thinking "this is going to be much more testable", since you have a flatter hierarchy with less direct dependencies. Reminds me a bit of Smalltalk's late binding and the Lua-based game engine Defold's message system -- instead of having a complicated and brittle web of direct dependencies, scripts just broadcast messages and listen for ones they care about.
@Gexsi06 ай бұрын
I think you should also mention one more benefit. Your commands can be executed synchronously or asynchronously.
@phpannotated6 ай бұрын
True, thanks for pointing that out! I actually thought I mentioned it briefly, but I cut that part out last minute 😬
@turboclown6 ай бұрын
This is very interesting, I hope you'll give some examples in your blog or even open source the code you wrote. I'd love to learn.
@phpannotated6 ай бұрын
I plan on writing a post about it as well soon :)
@Plytys6 ай бұрын
Would like to see an example how you refactor some piece of code to command bus.
@phpannotated6 ай бұрын
Very nice idea! I might do a livestream about it soon :)
@Alpheus25 ай бұрын
@@phpannotated Happy to pair on stream if you want some backup on the refactor plus discussion.
@bambamboole16 ай бұрын
It’s a very powerful pattern, when you get used to not return stuff from the handlers. Then all of the commands can be easily queued. Connect it via events with websockets to the frontend again and it feels like a super power.
@jelmerprins6 ай бұрын
As a big fan of command busses and the number 1 on the leaderboard of the game, thank you :D I am a bit sad that i have to adjust my deck since something got fixed that was apparently a bug, but the game is still a lot of fun. I would disagree on the crud app though, but maybe that is a symfony vs laravel thing. I also find it useful for crud and with a maker I can easily generate most of the code
@Aerendir6 ай бұрын
Can you explain better what do you mean with “with a maker I can easily generate most of the code”? 🙏🏻
@jonashansen25126 ай бұрын
A little bit of CQRS goes a long way 😊
@AlexMerlin19856 ай бұрын
4:44 That missing closing parenthesis after the call to command, though... :)
@phpannotated6 ай бұрын
Oh oh 😳
@robwatson8266 ай бұрын
I love a command bus. Glad you've seen the light! Interested to know how you handle situations where the command changes some data and you want to send that data back to the client? Do you just make a new query to fetch the updated data? Or do you leave that up to the client to make another request for it?
@phpannotated6 ай бұрын
If you follow CQRS, then commands and querying are indeed two concernes that are fully separated. That means no returning from handlers directly. It means that after having dispatched a command, you'll have to re-query the read model manually. I briefly mentioned it in the video, but it's a super interesting topic that's probably worth some content on its own.
@roky28226 ай бұрын
@@phpannotated can you recommend good information sources about CQRS. I can google myself sure, but I'm interested which sources would you personally recommend?
@phpannotated6 ай бұрын
@@roky2822 I once wrote a blog post where I bundled the talks that got me started, it's a good entry point :) stitcher.io/blog/my-journey-into-event-sourcing If you want to learn more, Greg Young's talks are excellent :)
@anupam.sam96 ай бұрын
Can you link your project in the description for better understanding of the full implementation...?
@phpannotated6 ай бұрын
It's not open source at the moment. But I will do some livestreams about it in the future :)
@NedumEze6 ай бұрын
Never heard of 'Command Boss'. Is it your invention? Any plans for literature or articles on it?
@phpannotated6 ай бұрын
😂
@xiCO2k6 ай бұрын
Next refactor should be change from PHPUnit to Pest 🌶
@Hatecultist6 ай бұрын
Little suggestion for the audio: I think a DeHesser is needed
@phpannotated6 ай бұрын
Good point, I think it's because I was sick while recording and not breathing properly. I actually have a deesser enabled, but I should have tweaked it some more for this video.
@oladoyinbov6 ай бұрын
Command bus? Is it like a list of class object, grouped together to be dispatched somewhere else? I am kinda confused here