Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 should 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.

like image 509
Alexander Molodih Avatar asked Sep 22 '11 07:09

Alexander Molodih


People also ask

What is interface design in software design?

User interface (UI) design is the process designers use to build interfaces in software or computerized devices, focusing on looks or style. Designers aim to create interfaces which users find easy to use and pleasurable. UI design refers to graphical user interfaces and other forms—e.g., voice-controlled interfaces.

What is an interface software?

Software interfaces (programming interfaces) are the languages, codes and messages that programs use to communicate with each other and to the hardware. Examples are the Windows, Mac and Linux operating systems, SMTP email, IP network protocols and the software drivers that activate the peripheral devices.

Why would you as a software developer use interfaces?

Interfaces allow you to make the coupling between your classes very loose. Classes should be developed and tested in isolation with few or no external dependencies. But they almost certainly have to depend on something.

What is an interface in software architecture?

An interface is a boundary across which two independent entities meet and interact or communicate with each other. The characteristics of an interface depend on the view type of its element. If the element is a component, the interface represents a specific point of its potential interaction with its environ- ment.


2 Answers

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 :)

like image 170
iDevForFun Avatar answered Oct 11 '22 02:10

iDevForFun


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.

like image 24
Nahum Avatar answered Oct 11 '22 02:10

Nahum