Interface Design by Bill Venners
Make common things easy, rare things possible
Advertisement
|
Interface Design |
Contents |
Previous |
Next
Simplify, simplify, simplify
Simplify the Semantics
-
Guideline: Make object semantics as easy to understand as possible.
-
Interfaces tell compilers and JVMs how to link to an object's methods.
-
Interfaces can also say a lot to programmers about semantics: how to use an
object.
-
Make common things simple, rare things possible.
-
Avoid modes.
-
Apply the principle of least astonishment. (Semantic
contracts should be unsurprising.)
-
Be suspicious of urges to solve the general case rather
than the specific problem.
-
Occam's Razor: Get rid of anything that isn't absolutely essential or absolutely understood.
Why Simple Semantics?
-
For people: Simple semantics makes objects easier to understand
and use.
-
Design by Contract and test suites help with "semantic discovery" and
robustness.
-
Design objects that communicate to programmers how to properly use them.
-
Simple semantics has nothing to do with computers; it has to do
with people communicating with people.
-
Machine designers explaining to machine users how to use their
machines (objects).