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

后端 未结 16 2269
离开以前
离开以前 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 00:59

    I think one of the reasons abstract classes have largely been abandoned by developers might be a misunderstanding.

    When the Gang of Four wrote:

    Program to an interface not an implementation.

    there was no such thing as a java or C# interface. They were talking about the object-oriented interface concept, that every class has. Erich Gamma mentions it in this interview.

    I think following all the rules and principles mechanically without thinking leads to a difficult to read, navigate, understand and maintain code-base. Remember: The simplest thing that could possibly work.

提交回复
热议问题