O'Reilly logo

Eloquent JavaScript by Marijn Haverbeke

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

Predictability

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required