29.11.2014 Views

Smalltalk and Object Orientation: an Introduction - Free

Smalltalk and Object Orientation: an Introduction - Free

Smalltalk and Object Orientation: an Introduction - Free

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Table 24.2: Class message categories<br />

Protocol<br />

inst<strong>an</strong>ce creation<br />

class initialization<br />

examples<br />

private<br />

Use<br />

Used for methods associated with creating inst<strong>an</strong>ces<br />

Methods which initialize class variables<br />

Methods which illustrate some use of the class, e.g. inst<strong>an</strong>ce<br />

creation<br />

Methods that provide support for one of the above<br />

Table 24.2 illustrates the common class message protocols <strong><strong>an</strong>d</strong> what they are used for. Table 24.3<br />

does the same thing for the inst<strong>an</strong>ce message protocols. Notice the practice of naming inst<strong>an</strong>ce message<br />

protocols as actions. These actions are intended to indicate the type of activity being performed. A n<br />

exception to this is the initialize (or its vari<strong>an</strong>t initialize -release) protocol. Although this does not<br />

conform to the st<strong><strong>an</strong>d</strong>ard it is consistent throughout the VisualWorks image <strong><strong>an</strong>d</strong> you are therefore<br />

advised to comply with this exception.<br />

Table 24.3: Inst<strong>an</strong>ce message categories<br />

Category<br />

accessing<br />

adding<br />

converting<br />

comparing<br />

displaying<br />

initialize<br />

printing<br />

updating<br />

Use<br />

Methods used for accessing <strong><strong>an</strong>d</strong> updating inst<strong>an</strong>ce variables.<br />

Used in collection classes for methods which add elements to the<br />

collection.<br />

Holds methods which convert one inst<strong>an</strong>ce into <strong>an</strong>other inst<strong>an</strong>ce.<br />

Groups methods used for comparison tests.<br />

Holds methods which relate to displaying information graphically<br />

Holds methods which initialize the inst<strong>an</strong>ce.<br />

Methods associated with printing the inst<strong>an</strong>ce such as printString<br />

Used to hold methods which cause some ch<strong>an</strong>ge in the inst<strong>an</strong>ces<br />

state.<br />

24.6 Further reading<br />

There are a number of places which c<strong>an</strong> provide very useful further reading, f or example [Skublics et al<br />

1996] is <strong>an</strong> excellent little book which really does provide pearls of wisdom on good <strong>Smalltalk</strong> style. It<br />

is a book to be dipped into, rather th<strong>an</strong> read from cover to cover. However, if you do m<strong>an</strong>age to<br />

inwardly digest this book, you will be able to write clear, concise, reusable <strong>Smalltalk</strong>. In addition m<strong>an</strong>y<br />

of the core system classes also provide excellent examples of the good <strong>Smalltalk</strong> style.<br />

203

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

Saved successfully!

Ooh no, something went wrong!