C # when to program on the interface?

Well, the most important thing in programming an interface is that it allows you to exchange certain classes while new classes implement everything in that interface.

eg. I program my dataSource object on an interface, so I can change it between the xml reader and the sql database reader.

Does this mean that every class must be programmed into an interface? When is it not recommended to use the interface?

+5
source share
8 answers

When does the YAGNI principle apply.

, , , , . , , .

+11

. , , . , , - .

, , . , , , , , IComponent , .

+4

, . , , .

, . , ( #, ), , REAL.

, , DTO, , , , , .

, , ; , (, hehe), , , , .

+4

, , , . , , , , ICustomer. , s.a. " ", , , ISavable.

- . , ypu SMS-, SMS , , , s.a. ISmsGatewayAdapter, , .

"dependecy injection",

+1

: ? , - .NET, ! .

, - , , .

, " ?" . . , , , , , , .

0

. , , StructureMap, "... IWidget", . , , , . , , , , , , .. , . , , . SOLID-, .

0

, , , . Err .

YAGNI.

0

Visual Studio, , ( ). .

, . , .

0

All Articles