- Hands-On Dependency Injection in Go
- Corey Scott
- 160字
- 2021-06-10 19:17:48
How does this relate to DI?
As we have seen, the ISP helps us to break down interfaces to logically separate parts, with each part providing a particular feature—a concept sometimes referred to as a role interface. By leveraging these role interfaces in our DI, our code becomes decoupled from the concrete implementation of the inputs.
Not only does this decoupling allow parts of the code to evolve separately, but it also tends to make it easier to identify test vectors. In the previous example, it's easier to scan through the inputs one at a time and consider their possible values and states. This process might result in a list of vectors like the following:
Test vectors for the value input include:
- Happy path: Returns a valid value
- Error path: Returns an empty value
Test vectors for the monitor input include:
- Happy path: Does not return a done signal
- Error path: Immediately returns a done signal
推薦閱讀
- Java逍遙游記
- Hyper-V 2016 Best Practices
- Responsive Web Design with HTML5 and CSS3
- 云原生Spring實戰(zhàn)
- Scratch 3游戲與人工智能編程完全自學(xué)教程
- 秒懂設(shè)計模式
- TypeScript圖形渲染實戰(zhàn):基于WebGL的3D架構(gòu)與實現(xiàn)
- Java Web開發(fā)技術(shù)教程
- Python漫游數(shù)學(xué)王國:高等數(shù)學(xué)、線性代數(shù)、數(shù)理統(tǒng)計及運籌學(xué)
- Big Data Analytics
- Scientific Computing with Scala
- Swift細致入門與最佳實踐
- Java EE 8 Application Development
- 深入分布式緩存:從原理到實踐
- Python機器學(xué)習(xí)之金融風(fēng)險管理