18.01.2013 Views

Objects, Components, and Frameworks with UML The Catalysis ...

Objects, Components, and Frameworks with UML The Catalysis ...

Objects, Components, and Frameworks with UML The Catalysis ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Java Interfaces: which behaviors are OK?<br />

© ICON Computing<br />

interface awt.ListBox { // not exactly awt.List<br />

// represents a list of items to be offered on a GUI<br />

void addItem (Item, int);<br />

Item delItem (int);<br />

…<br />

}<br />

addItem<br />

delItem<br />

position?<br />

position?<br />

addItem<br />

delItem<br />

❒ Only some implementations are valid<br />

• <strong>The</strong> signature-based interfaces does not specify which<br />

Consider a simple Java interface shown above. <strong>The</strong> signatures alone do not adequately specify the required behavior<br />

e.g. are items positions counted from the front or back? Starting at 0 or 1? What happens if I add at a position<br />

beyond the current contents? What does add do to the item already at a position, if any?<br />

© ICON Computing http://www.iconcomp.com<br />

22<br />

22

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!