update
This commit is contained in:
parent
21468e47de
commit
b69830a7fd
68 changed files with 12438 additions and 0 deletions
22
Readwise/Dependency Injection, the Best Pattern.md
Normal file
22
Readwise/Dependency Injection, the Best Pattern.md
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
# Dependency Injection, the Best Pattern
|
||||
|
||||

|
||||
|
||||
## Metadata
|
||||
- Author: [[CodeAesthetic]]
|
||||
- Full Title: Dependency Injection, the Best Pattern
|
||||
- Category: #articles
|
||||
- URL: https://www.youtube.com/watch?v=J1f5b4vcxCQ
|
||||
- Archive: https://web-archive.alecodes.page/bookmarks?bf=1&search=&title=Dependency%20Injection%2C%20the%20Best%20Pattern
|
||||
> [!tldr]
|
||||
> The text explains how to use dependency injection to build an attachment service that uploads files. By creating an interface for storage and injecting it into the request handler, the code becomes simpler and less error-prone. This approach also allows for easy testing with mock implementations.
|
||||
|
||||
## Highlights
|
||||
have a piece of code which uses another piece of code, and instead of using that code directly, it's passed in instead. [View Highlight](https://read.readwise.io/read/01j8b4fbn7xc4day63pshpds1t))
|
||||
|
||||
Injection basically just lets us pick and choose from our compatible puzzle pieces and then slot them in when we need them. [View Highlight](https://read.readwise.io/read/01j8b51ysp8pj6g1sk4cc94qzp))
|
||||
|
||||
We can use injection to inject fake or mock implementations instead, which basically means we can slice and dice up our architecture to isolate sections of code during testing. [View Highlight](https://read.readwise.io/read/01j8b54d9xcz7p57m37apc92xm))
|
||||
|
||||
A natural side effect of having nice code is that it's easy to test without needing to hack around the code structure. If you find yourself asking, how can I test a private method? Or I need to set some internal variable in order to test. That's a signal that you maybe need to pull some stuff out, that you need to isolate some part of it by separating it and injecting it instead. [View Highlight](https://read.readwise.io/read/01j8b57129cky28vhfsq2fd38y))
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue