|
Take a Hint
Listing 1. Your DbC annotations can be a good source of hints if you are developing based on a Design-by-Contract methodology and you document preconditions and postconditions for methods. public class SimpleSet
{
/** @post this.isEmpty()
*/
public SimpleSet()
{
//...
}
/** @post this.contains(item)
* @post !this.isEmpty()
*/
public void add(Object item)
{
//...
}
/** @pre !this.isEmpty()
* @pre this.contains(item)
* @post !this.contains(item)
*/
public void remove(Object item)
{
//...
}
public boolean contains(Object item)
{
//...
return false;
}
public boolean isEmpty()
{
return false;
}
}
|