Dependency Injection basics- Fun Fun Function

preview_player
Показать описание
💖 Support the show by becoming a Patreon

Dependency injection (here shown using JavaScript) is a software design pattern that is primarily to make code unit testable, by moving the responsibility for getting dependencies outside the code that depends on it. It does require some restructuring of your application, which feels a bit wrong to do just to get testability, but it’s an otherwise remarkably simple pattern that gets the job done.

🔗 Code from the episode

🔗 Promises in JavaScript video

🔗 Fetch API video

🔗 Composition over inheritance (Other video referenced at the end)

🔗 Mocha (test runner for JavaScript)

🔗 npm (package manager for JavaScript)

🔗 Music: Peacock by 7 minutes dead

🔗 Music: Funky One by Incompetech

🔗 FIGHT by Tokyo Machine

💛 Follow on Twitch
We record the show live Mondays 7 AM PT

💛 Fun Fun Forum

💛 mpj on Twitter

💛 CircleCI (Show sponsor)
Robust and sleek Docker-based Continuous Integration as a service. I used CircleCI prior to them becoming a sponsor and I love that their free tier is powerful enough for small personal projects, even if they are private. Use this link when you sign up to let them know you came from here:

💛 Quokka (Show sponsor)
Wonder how MPJ evaluates JavaScript inline his editor. Quokka is the answer - use this link when you buy to let them know you came from here:

💛 FUN FUN FUNCTION
Since 2015, Fun Fun Function (FFF) is one of the longest running weekly YouTube shows on programming 🏅 thanks to its consistency and quality reaching 200,000+ developers.

🤦‍♂️ The Failing Together concept is what makes FFF unique. Most coding content out there focus on step-by-step tutorials. We think tutorials are too far removed from what everyday development is like. Instead, FFF has created a completely new learning environment where we grow from failure, by solving problems while intensively interacting with a live audience.

Tutorials try to solve a problem. Failing Together makes you grow as a developer and coworker.

📹 Each show is recorded live on Twitch in a 2-hour livestream on Mondays. The host, assisted by the audience, is tasked to complete a programming challenge by an expert guest. Like in the real world, we often fail, and learn from it. This, of course, reflects what the audience identifies with, and is one of the most praised aspects of the show.

⏯ On Fridays, an edited version of the show is adapted for and published on YouTube.

Content Topics revolve around: JavaScript, Functional Programming, Software Architecture, Quality Processes, Developer Career and Health, Software Development, Project Management
Рекомендации по теме
Комментарии
Автор

I love that you stop to explain each tool and api you use. Wish more folks did that 👏🏼🏄🏻‍♀️

Noopkat
Автор

"This is one of the benefits of unit testing, you can run your test over and over and get a hit of dopamine to your brain every time" 17:28

zyin
Автор

I'm fairly new to Javascript testing. I think it would be extremely helpful and entertaining if you were to create a testing series like that of functional programming

jessemccarthy
Автор

dude how are you so good honestly, this was insanely easy i look around for like 200 videos this the only one that makes sense lol

shady
Автор

Great vid as always! Thanks for always including your mistakes in the video as well. It really helps establish the thought process behind troubleshooting the issues that folks are inevitably going to experience when starting in on this themselves.

trxjw
Автор

I didnt expected the explaination to be this good he actually nailed it, thanks man understood it well

Somin
Автор

Dude, I think I love you. Love the approach, love the funny irreverence. Still learning from you. Keep it up, if there's still anything left to talk about....

jamesmcrayjohnsoniii
Автор

I love how this explained both Depedency Injection and Unit Testing fetch functions through mocking in javascript at the same time (although it focused much more at unit testing). I took a couple of hours just looking at it and understanding the bits and pieces from everything, trying to deduce how to worked before you explained in the end, and I learnt so much from it. Great video MPJ!

Marcosmapf
Автор

These are my favorite types of videos you do! Explain a problem, then walk us through how XXX solves that problem. Great stuff!

ChrisGeirman
Автор

OMG! Awesome, clear, elegant, and a little bit silly!! JUST the way learning should always be! I LOVE your videos and explanations. Thank you so much for making them!

marti
Автор

I miss this guys videos. His were the best

djcardwellai
Автор

Re. Mocha and asynchronous tests: If you are executing a promise, and the test is complete when the promise is resolved, you can simply return the promise itself. Mocha will wait for it, and will treat rejections as if they were thrown exceptions.

Unexpected (an excellent extensible TDD assertion system) uses this trick extensively.

autochton
Автор

Always enjoy listening to him...would be lovely if he had capitalized on how to test the version where fetch is not passed in as a dependency by trying to write a test for it and showing what road block we would hit...that's my only comment. Thanks :)

samaneh
Автор

I love this show. It's like learning programming concepts from Jim Carrey.

shahrin
Автор

Man! Your channel is such a breath of fresh air!

zachpratt
Автор

Awesome video, I will start using Dependency Injection immediately.

Thanks a lot for the time you dedicate to produce this videos.

johnnyzabalasanchez
Автор

I really liked your explanation, very simple and helped me understand it. So rather than referencing outside objects/instances from within the function, you pass in the objects/instances that the function will be using (it's dependencies) explicitly during the call/construction of the function/class. <- My own words, so I cement it in to my memory better.

KjKase
Автор

Great video! Its probably worth mentioning that there are newer alternate methods to dependency injection such as mocking module imports (Jest mocks).

Purelysubs
Автор

This was great, I love the code-heavy eps that go into more depth on a specific technique. Thanks!

DanielMinshewTheInternet
Автор

Man I miss your videos! Hope all is well!

GorillaDev
welcome to shbcf.ru