To use the 'I' prefix for interfaces or not to

前端 未结 20 1428
长情又很酷
长情又很酷 2021-02-01 02:54

That is the question? So how big a sin is it not to use this convention when developing a c# project? This convention is widely used in the .NET class library. However, I am not

相关标签:
20条回答
  • 2021-02-01 03:50

    Using I for interfaces goes against the whole point of an interface imo, that it is a connector that you can plug different concrete implementations in to dependencies.

    An object that uses the database needs a DataStore, not an IDataStore, and it should be up to configuration whether that gets a DatabaseDataStore or a FileSystemDataStore or whatever plugged into it (or a MockDataStore for testing).

    0 讨论(0)
  • 2021-02-01 03:52

    I stick to the convention only because I have to, if I am to use any interfaces in the BCL and maintain consistency.

    I don't like the convention, either.

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