Whenever I think the words "copy and paste" or hear another developer utter them, a big red alarm goes off in my mind 🚨So as soon as you said these fated words when going to make the ethereum asset, I was on alert and noticed you'd not set the ticker code to ETH and the name was still bitcoin. It's just as important for your tests to be DRY (Don't Repeat Yourself) as much as it is for your production code. Even when making a course, you fell foul of not applying this principle. So it was actually a good demonstration of why DRY is so important! Whenever thinking or hearing "copy and paste", it should be a trigger to make you refactor the code so you don't need to do that, e.g. write a helper method in the test to create an asset given its ticker code, name and price. It has the added benefit of making the test more readable ;)
2 года назад+1
Thanks for the comment Mike! In real life I’d probably resort to adding some predefined states on the AssetFactory class - as for repetition, more often than not replacing it with an abstraction makes things less obvious (this obviously depends on the situation). While recording a screencast it’s hard to keep track of everything, but I appreciate your comment - I’m sure it’ll be of help to lots of folks later!
Thanks for the awesome and informative video. Question tho; why do you like to use a static make() function instead of calling the class via the new keyword?
3 года назад
Thanks Robin! No specific reason. I was just doing things on the go and I thought I'd need to parse something for the constructor.
Whenever I think the words "copy and paste" or hear another developer utter them, a big red alarm goes off in my mind 🚨So as soon as you said these fated words when going to make the ethereum asset, I was on alert and noticed you'd not set the ticker code to ETH and the name was still bitcoin. It's just as important for your tests to be DRY (Don't Repeat Yourself) as much as it is for your production code. Even when making a course, you fell foul of not applying this principle. So it was actually a good demonstration of why DRY is so important! Whenever thinking or hearing "copy and paste", it should be a trigger to make you refactor the code so you don't need to do that, e.g. write a helper method in the test to create an asset given its ticker code, name and price. It has the added benefit of making the test more readable ;)
Thanks for the comment Mike!
In real life I’d probably resort to adding some predefined states on the AssetFactory class - as for repetition, more often than not replacing it with an abstraction makes things less obvious (this obviously depends on the situation).
While recording a screencast it’s hard to keep track of everything, but I appreciate your comment - I’m sure it’ll be of help to lots of folks later!
@ could you give an example of an abstraction that would make the code less obvious in this situation of creating an asset?
Hi Mateus, what vscode extension are you using for laravel and php, thanks!
Excellent video, loved it! May I ask about your VS Code setup? Like, what extensions you use to get labelled arguments?
PhpStorm Parameter Hints in VScode
Good video, I really had fun watching it. 👍
Thanks for the awesome and informative video. Question tho; why do you like to use a static make() function instead of calling the class via the new keyword?
Thanks Robin!
No specific reason. I was just doing things on the go and I thought I'd need to parse something for the constructor.
@ Hi Mateus, what vscode extension are you using for laravel and php, thanks!
Hey Mathew! Nice video. Can you help with your vscode setup for php laravel
I like the way the function arguments are labeled. This emulates phpstorm
@@rabotherabo I was going to ask the same thing!