Chapter 4. State

Sure, how you specify behavior is most important in coding Smalltalk objects, but you still won’t get anywhere without state. Before you start a computation, something has to record what the problem is. While you are computing, you often need to store intermediate results. When you finish a computation, you have to remember the answer.

Most state-related decisions have more to do with modeling and less with coding, so the patterns here don’t tell anything like the whole story. However, the tactical decisions you make about representation will have an important impact on how well your code communicates with others.

This section talks about two kinds of state: instance variables and temporary variables. Of the two, temporary variables ...

Get Smalltalk Best Practice Patterns now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.