Why use scala's cake pattern rather than abstract fields?

前端 未结 4 846
孤街浪徒
孤街浪徒 2020-12-15 04:51

I have been reading about doing Dependency Injection in scala via the cake pattern. I think I understand it but I must have missed something because I still can\'t see the

4条回答
  •  一整个雨季
    2020-12-15 05:12

    Think about what happens if TwitterService uses TwitterLocalCache. It would be a lot easier if TwitterService self-typed to TwitterLocalCache because TwitterService has no access to the val localCache you've declared. The Cake pattern (and self-typing) allows for us to inject in a much more universal and flexible manner (among other things, of course).

提交回复
热议问题