Skip to main content Accessibility help
×
Hostname: page-component-7479d7b7d-t6hkb Total loading time: 0 Render date: 2024-07-13T17:36:16.757Z Has data issue: false hasContentIssue false

16 - TO ACCESSOR OR NOT TO ACCESSOR

Smalltalk Report, June, 1993

Published online by Cambridge University Press:  04 August 2010

Kent Beck
Affiliation:
First Class Software, Inc.
Get access

Summary

Why do I keep doing this? I keep bringing up the “should all variables be accessed through methods” debate whenever I see people taking a dogmatic position, that is, one that they don't explain. It wasn't until I rewrote the whole thing as patterns for the book that I realized the key issue here is communication.

I'm a little disappointed reading this now that I didn't try to write Direct Access and Indirect Access as patterns. That would have made the reasoning behind the options much more obvious. I guess I just wasn't ready to use patterns to address such fundamental questions. Now I don't even hesitate- I'm so pattern soaked now I can't help it.

Anyway, if this one bugs you, ignore it, all except the part about making accessors private by default.

A debate has been raging on both CompuServe and the Internet lately about the use and abuse of accessing methods for getting and setting the values of instance variables. Since this is the closest thing I've seen to a religious war in a while, I thought I'd weigh in, not with the definitive answer, but with at least a summary of the issues and arguments on both sides. As with most, uh, “discussions” generating lots of heat, the position anyone takes has more to do with attitude and experience than with objective truth.

Type
Chapter
Information
Kent Beck's Guide to Better Smalltalk
A Sorted Collection
, pp. 175 - 180
Publisher: Cambridge University Press
Print publication year: 1997

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

Save book to Kindle

To save this book to your Kindle, first ensure coreplatform@cambridge.org is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.

Note you can select to save to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.

Find out more about the Kindle Personal Document Service.

  • TO ACCESSOR OR NOT TO ACCESSOR
  • Kent Beck, First Class Software, Inc.
  • Book: Kent Beck's Guide to Better Smalltalk
  • Online publication: 04 August 2010
  • Chapter DOI: https://doi.org/10.1017/CBO9780511574979.019
Available formats
×

Save book to Dropbox

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Dropbox.

  • TO ACCESSOR OR NOT TO ACCESSOR
  • Kent Beck, First Class Software, Inc.
  • Book: Kent Beck's Guide to Better Smalltalk
  • Online publication: 04 August 2010
  • Chapter DOI: https://doi.org/10.1017/CBO9780511574979.019
Available formats
×

Save book to Google Drive

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Google Drive.

  • TO ACCESSOR OR NOT TO ACCESSOR
  • Kent Beck, First Class Software, Inc.
  • Book: Kent Beck's Guide to Better Smalltalk
  • Online publication: 04 August 2010
  • Chapter DOI: https://doi.org/10.1017/CBO9780511574979.019
Available formats
×