views:

109

answers:

3

When I read articles on software development, I often heard of the phrase "clean interface". People talked about clean interface for APIs, and classes.

How do you define "clean interface"? Is there any guideline for designing a system with clean interface?

+2  A: 

A "clean interface" is one that doesn't leak implementation details. It's easy to understand, doesn't expose its private parts, and doesn't result in excessive coupling between you and the code you're interfacing with. It's more of a code smell than a strict definition...

Andrew
+1 I agree I would also add that properties are not repetitives. If you encounter the same method or property in more than one interface which purpose is quite the same as the other, perhaps you'd better opt for a higher level interface from which the your others will derive from.
Will Marcouiller
+3  A: 

Whole books have been written on this, and Framework Design Guidelines (.NET-centric) is one of my favorites. There's a lot to it, and no simple answer, but if I were pressed for a simple answer, I'd say design an API so that the simple stuff can be done without the dev having to read any extended documentation. That implies a straightforward, consistent interface with sensible, descriptive names. Don't make it hard to do the basic stuff.

Michael Petrotta
+1  A: 

Keep it simple and write lean and swift, self-explanatory code. One that is easy to read and to maintain.

Will Marcouiller