Squeak messages and parts of (English) Speech
Last updated at 8:27 am UTC on 5 January 2007
The number of arguments, the object returned, and the action taken can be used to classify methods into parts of speech.
Noun, verb, adjective, preposition.
Objects or the variables that hold objects are usually nouns.
One word methods that return a modified object are adjectives.
In English adjectives will usually end in -ed.
- Example: aPoint truncated reads better than aPoint truncate.
Methods with one parameter or more usually serve as verbs.
This is particularly true for methods that do not explicitly return an answer.
Predicates usually start with is- or has- and return a Boolean.
fooBar isPoint ifTrue: [ ...]
Variables or iVars that contain booleans read easier if they also start with is- or has-.
Inside of a complicated [ ...] doWhileTrue/doWhileFalse block ,
it will increase readability to name a variable to stand in for the boolean
repeat := true. and done := doNext := false .
then the block reads [ .... hasFooed ifTrue: [ repeat ] ifFalse: [ done ] ] ...
and you don't have to find the doWhileXXX to figure out what is going on.
If an object is meant to act on something (E.g. BitBlt or WarpBlt) it is the noun form of a verb.
In English nomilizations of verbs usually end in -er
warper := WarpBlt new .
Sounds good when you read it.
Prepositons are used to attach objects to an object or action.
Array with: $a.
WriteSream on: ...
aSomething with: anotherSomething for: stillAnotherSomething.
Again this is a work in progress. Feel free to construtively add.
As this is brainstoming please do not put criticisms on this page.
Links to opposing points of view are okay. -wiz