paint-brush
Dependency Injection to Make Your Code Testable [A How-To Guide]by@thawkin3
582 reads
582 reads

Dependency Injection to Make Your Code Testable [A How-To Guide]

by Tyler Hawkins6mMarch 26th, 2020
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Dependency Injection to Make Your Code Testable [A How-To Guide] is a simple technique to make your code easier to test. The W3Schools technique is called dependency injection. It lets the developer use a function to pass its dependencies through arguments. The technique is a pretty straightforward yet incredibly powerful technique. Let’s say you want to write a JavaScript function that can parse individual cookie key-value pairs out of the JavaScript code. For example, here is how to do this: getCookie (cookieName)

Company Mentioned

Mention Thumbnail

Coin Mentioned

Mention Thumbnail
featured image - Dependency Injection to Make Your Code Testable [A How-To Guide]
Tyler Hawkins HackerNoon profile picture
Tyler Hawkins

Tyler Hawkins

@thawkin3

Senior software engineer. Continuous learner. Educator.

About @thawkin3
LEARN MORE ABOUT @THAWKIN3'S
EXPERTISE AND PLACE ON THE INTERNET.
L O A D I N G
. . . comments & more!

About Author

Tyler Hawkins HackerNoon profile picture
Tyler Hawkins@thawkin3
Senior software engineer. Continuous learner. Educator.

TOPICS

THIS ARTICLE WAS FEATURED IN...

Permanent on Arweave
Read on Terminal Reader
Read this story in a terminal
 Terminal
Read this story w/o Javascript
Read this story w/o Javascript
 Lite