Why do most system architects insist on first programming to an interface?

后端 未结 16 2285
离开以前
离开以前 2020-12-05 00:32

Almost every Java book I read talks about using the interface as a way to share state and behaviour between objects that when first \"constructed\" did not seem to share a r

16条回答
  •  遥遥无期
    2020-12-05 01:23

    I would assume (with @eed3s9n) that it's to promote loose coupling. Also, without interfaces unit testing becomes much more difficult, as you can't mock up your objects.

提交回复
热议问题