In their book Design by Contract by Example Richard Mitchell and Jim McKim state six elementary principles how to write good contracts:
Principle 1: Separate queries from commands.
Principle 2: Separate basic queries from derived queries.
Principle 3: For each derived query, write a postcondition that specifies what result will be returned, in terms of one or more basic queries.
Principle 4: For each command, write a postcondition that specifies the value of every basic query.
Principle 5: For every query and command, decide on a suitable precondition.
Principle 6: Write invariants to define unchanging properties of objects.
These six principles have been applied to all the examples on this website and the tutorials and case studies.