开发者

Software-design only with interfaces?

Is it good approach when in software-designing the class interactions are describe only with interfaces? If yes, should I always use this approach?

I must design class library that sh开发者_运维技巧ould have a high testability (I use C#).

This library have one facade and some amount of classes with different interactions in the background.

In the case of optimizing this library for good testability I've replace most part of my classes with interfaces.

And when I did this, I saw in a connection diagram (Visual Studio class diagram) only interfaces.

Is it normal decision of my problem? or there should be some another approach?

P/S: Maybe it's well known way in software-design but I can't find some confirmation in books that I have.


Yes this is good practice. It allows you to focus about the responsibilities of each class without getting concerned with implementation details. It allows you to see the method call stack and as you say gives a high level of testability and maintainability. You're on the right track as far as I see :)


Yes, that is generally a good practice.

I would recommend you to read a good design patterns book, for example this one.

it is targeted for Java developers but I had no trouble understanding all the examples as a C# developer.


By using interfaces you can decompose your applications into subsystems to make it maintenable and easily expandable. Some uses cases can be:

  • application may need to communicate more than one web service endpoints to to fullfill same functions such as direct billing or payment interfaces from different providers

  • data access layer class that execute SQLs to different Databases with different drivers.

  • processing different objects that implements the same interface using the same thread pool from the same queue

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜