Interface Design

Designing an interface for a module or an object type is one of the subtler aspects of programming. Any nontrivial functionality can be exposed in different ways. Finding a way that works well is something of an art.

The best way to learn the value of good interface design is, unfortunately, to use bad interfaces. Once you get fed up with them, you’ll figure out a way to improve them and learn a lot in the process. Try not to assume that a lousy interface is “just the way it is.” Fix it, or wrap it in a new interface that is better (we will see an example of this in Chapter 10).


If programmers can predict the way your interface works, they (or you) won’t need to look things up while working. Thus, try to follow conventions ...

Get Eloquent JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.