Good Case For Interfaces

前端 未结 17 1968
眼角桃花
眼角桃花 2020-12-14 04:29

I work at a company where some require justification for the use of an Interface in our code (Visual Studio C# 3.5).

I would like to ask for an Iron Clad reasoning t

17条回答
  •  有刺的猬
    2020-12-14 05:17

    To enable unit testing of the class.

    To track dependencies efficiently (if the interface isn't checked out and touched, only the semantics of the class can possibly have changed).

    Because there is no runtime overhead.

    To enable dependency injection.

    ...and perhaps because it's friggin' 2009, not the 70's, and modern language designers actually have a clue about what they are doing?

    Not that interfaces should be thrown at every class interface: just those which are central to the system, and which are likely to experience significant change and/or extension.

提交回复
热议问题