Thursday, October 25, 2007

XOM Design Principles

http://www.cafeconleche.org/XOM/designprinciples.xhtml

Design Goals

Absolutely correct
Easy to use
Easy to learn
Fast enough
Small enough
No gotchas

Design Principles

As simple as it can be and no simpler!
Use Java idioms where they fit
There’s exactly one way to do it
Start small and grow as necessary

Principles of API Design

APIs are written by experts for non-experts
It is the class’s responsibility to enforce its invariants
Verify preconditions
Do not allow clients to do bad things.
Hide as much of the implementation as possible.
Design for subclassing or prohibit it
Prefer classes to interfaces

XML Principles

All objects can be written as well-formed XML text
It is impossible to create malformed documents
Validity can be enforced by subclasses
Syntax sugar is not represented

Java Principles

Not thread safe
Classes do not implement Serializable; use XML.
Classes do not implement Cloneable; use copy constructors.
Lack of generics really hurts in the Collections API. Hence, don’t use it.
Problems detectable in testing throw runtime exceptions
Assertions that can be turned off are pointless
Setter and mutator methods return void

Development Style

This is a cathedral, not a bazaar
Unit testing
Static testing
Massive samples

No comments: