Smalltalk Best Practice Patterns (Kulbir Singh's Library) by Kent Beck

Smalltalk Best Practice Patterns (Kulbir Singh's Library) by Kent Beck

Author:Kent Beck
Language: eng
Format: epub
Publisher: Prentice Hall
Published: 1997-10-13T04:00:00+00:00


* * *

...self x...

* * *

I paused for a moment to remind myself that the message “x” was just fetching an instance variable. When I read:

* * *

...x...

* * *

I just kept reading.

I told Ward of my experience. He had another good explanation. When you write classes that only have a handful of methods, adding a getting and a setting method can easily double the number of methods in your class—twice as many methods to buy you flexibility that you may never use.

On the other hand, it’s awful frustrating to get a class from someone and see the opportunity to quickly subclass it, only to discover that they used Direct Variable Access, so there is no way to make the changes you want without changing most of the code in the superclass.

• Access and set the variable directly.

Most of the example code in this book uses Direct Variable Access because I want to be as easy to read as possible. When you have direct access, putting in Indirect Variable Access is no big deal. Thus, you can read:



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.