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

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

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

<strong>an</strong><strong>Object</strong> MyCar totalNumber<br />

A capitalization convention is used consistently throughout <strong>Smalltalk</strong> <strong><strong>an</strong>d</strong> most <strong>Smalltalk</strong><br />

programmers adhere to this st<strong><strong>an</strong>d</strong>ard which it is therefore advisable to follow:<br />

• Private variables (inst<strong>an</strong>ce/temporary variables) start with a lower-case letter.<br />

• Shared variables (class/global/ pool variables) start with <strong>an</strong> upper-case letter.<br />

Note that message selectors should start with a lower-case letter.<br />

Another convention worth noting is that if a variable or a message selector combines two or more<br />

words, the convention is to capitalize the first letter of the second word onwards. E.g.<br />

displayTotalPay, returnStudentName.<br />

If we consider our new method above, we have still to consider what happens in the assignment<br />

statement (:=). We shall look at this in the next chapter along with the r<strong>an</strong>ge of arithmetic functions<br />

available.<br />

68

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

Saved successfully!

Ooh no, something went wrong!