Why is proxying deprecated?

后端 未结 1 753
孤城傲影
孤城傲影 2021-01-14 22:20

This question about how to extend a Scala collection led me to this answer, which extends from SetProxy rather than Set. But SetProxy has since bee

相关标签:
1条回答
  • 2021-01-14 22:52

    Proxying is deprecated because it is fragile. A proxy is supposed to forward all calls back to some other implementation. But what if you add a new method to the Set hierarchy--will anyone remember to add it to SetProxy and make sure it points where it should?

    In practice, there was no good way to verify that proxies were actually functioning correctly. So the decision was made that it's better to not have the functionality at all than to have something that looks like it works but actually doesn't any more. Compiler support for proxying might make it easy enough to maintain robust proxies, but the manual approach just isn't robust enough.

    0 讨论(0)
提交回复
热议问题