Skip to Main Content
Prefactoring
book

Prefactoring

by Ken Pugh
September 2005
Intermediate to advanced content levelIntermediate to advanced
240 pages
6h 28m
English
O'Reilly Media, Inc.
Content preview from Prefactoring

3.5. Consistency Is Simplicity

Consistency is a form of simplicity. Consistency makes it easy to deal with the world. Can you imagine using your cell phone if every time you turned it on, another revision of the user interface was downloaded to it? However, too much consistency can inhibit creativity. You should apply consistency with a purpose. "A foolish consistency is the hobgoblin of little minds" (Ralph Waldo Emerson).

Consistency is not just following code style conventions.[*] It is doing similar things in a similar manner, unless there is a good reason to change. If you are going to use exceptions, come up with guidelines for what types of events are exceptions and what types are not. For example, should the failure to find a customer with a particular name be an exception or an expected condition? Is it the caller's or the callee's responsibility to check contracts? Will a dozen callers contain the same checking code that could be stored once only, in a single callee?

[*] Gary K. Evans, a reviewer, tells programmers on his projects that the best they can do is to make their intent, or interface, intuitively obvious. The second-best thing they can do is to make it consistent, so once Evans learns it, at least it has consistency.

The development environment can provide consistency. For example, Borland JBuilder has a command that creates a listener for events. A separate listening class is created for each event, along with a separate method that is used to code the response ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Understanding Unittest.Mock

Understanding Unittest.Mock

Mario Corchero
Java™ Performance

Java™ Performance

Charlie Hunt, Binu John

Publisher Resources

ISBN: 0596008740Supplemental ContentCatalog PageErrata