First page Back Continue Last page Overview Graphics

Analogy Patterns in Software Statement Shape

private boolean isValid()


if (expirationDate == null ||

!( expirationDate.getTime() > 0 ) )

return false;

if (contractNumber == null ||

!(contractNumber.longValue() > 0) )

return false;


In this example we can identify the varieties of the analogy from the similarity of the shape of code statements.

The varieties are represented by the fields of the class (expirationDate and contractNumber).

The isValid operation is implemented for each field variety in the statement group.

This allows us to represent either an attribute or a behaviour but still limits us to one.