justforfunc #29: dependency injection in a code review
Вставка
- Опубліковано 10 лют 2025
- Dependency Injection (aka Inversion of Control) is a great technique to write code that is easier to reuse and test.
In this episode we review github.com/ger... and as a result create a pretty large PR: github.com/ger...
References:
PR: github.com/ger...
Dependency Injection: en.wikipedia.o...
filebuffer: github.com/mat...
proposal on bytes.Buffer.Seek: github.com/gol...
Your code reviews videos are bridging the gap between the theoretical aspects and the practical aspects, how they are being implemented. Keep making such awesome videos.
my favorite format - i learn a lot by going through code review process with clear explanation and examples.
Well Go you!
Watching you do the go, is really an symfony orchestra for me brain, beautiful.
Great. Wish every other tech youtubers should follow your way of code review live ... Learnt a lot lot.. thanks.
The reason for separate read/write file is probably because seek is stateful. If you write from one thread and read from another there is a good chance that you will corrupt the file. However, two threads concurrent writing will corrupt the file (two concurrently reading threads will read corrupt data) - so a mutex would have probably been best anyway.
Yeah, if you read the PR you'll see I added a RWMutex to DB :)
Predictably helpful :-) Thank you, Francesc!
Thanks for watching! :-)
I think I need to rewatch this video several times to get the whole refactoring process :) nice!
Enjoyed the episdoe !
23:03 - Am I'm not going to document it because that's not my problem. 😂
The speed up music was perfect!
Baroque music for baroque tasks 😁
You are just awesome :-)
You improved the audio quality a lot! :)
Well done. I like your code reviewing videos.
Hi Campoy!
Wouldn't make more sense instead of type embedding Storage in Service, create a GetSetDeleter, embed it in Storage and then use the Service as a GetSetDeleter? I have two points regarding this:
1. Len() is being embedded in Service but it's not used by it.
2. Sounds odd to me thinking a service as a "Storage", since this it just what it says it is, a service. Using GetSetDeleter would make more sense in my head.
Just let me know what you think about it.
Cheers!
Yeah, also you have to keep in mind difference between service.Set() and service.Storage.Set() all the way you are coding. It's confusing.
Yeah that's exactly my doubt too.
If we have to add more methods to Storage signature to handle different Service that means we have more useless methods in current Service.
Very good, as expected. Thanks!
you are supergeil) Thank for video
Really great Francesc, thank you. I am just wondering if you use some kind of ioc container to do the dependecy injection. If you do can you show us?
Love the JustForFunc, by the way, I'm waiting for the part 2 of CSVQL
Great video as always
Great video, Thank you Francesc!
Like you review
We need more of this! Why did he stop?
I guess Apple has a different attitude towards this. Even if they'd allow him to continue to teach us for free, that best must happen on iTunes, not here, in Google-land... 🙄
@ 19:26 the bytes.Buffer cannot be used because it is not a seeker, but bytes.Reader is. Why not use bytes.Reader?
How do you navigate code written with interfaces? Vscode isn't much helpful since it jumps to the interface definition while you probably want to jump into the implementation.
Seems to be a shortcoming of vscode-go. Normally Shift+F12 shows all occurrences - uses and implementations.
But when there is an interface in the way you're not able to find implementations from a use (and vice versa).
I lost the episode telling about VScode. Can't find it. Anyone can post a link?
Now you can use Uber's dig package to glue things together in main 👍🏼
Awesome video
Nice~
"The names are not great, but whatever"
No. Not "whatever"!
The video would be an hour long if I reviewed everything.
Whatever, in this context, means I won't get in the details but read the PR linked in the description for all the gory details
Like you review