Going bananas with loose coupling and dependency injection

后端 未结 4 1561
被撕碎了的回忆
被撕碎了的回忆 2021-01-31 20:42

With the latest additions to our dependency injection framework (annotations in spring), the marginal cost of creating DI-managed components seems to have hit some critical new

4条回答
  •  执念已碎
    2021-01-31 20:55

    Pure DI perfect universe, I think single classes+method design is ideal. In reality we need to balance the cost of that which makes it less feasible.

    Cost factors

    • Overhead of DI. Spinning up all the underlying and related underlyings for a single method is expensive. Grouping into a class allows us to offset some of that.
    • Skills - DI is new to many (myself ESPECIALLY) so understanding how to do it better or get out of old/habitual designs is tough
    • Brown field apps which have them already, it's easier/cheaper/quicker to live with them and worry about this in future green field apps

    Hopefully my newbie-ness (yes, I am filled with made up words) with DI hasn't made me completely wrong with this.

提交回复
热议问题