Skip to main content Accessibility help
×
Hostname: page-component-cd9895bd7-p9bg8 Total loading time: 0 Render date: 2024-12-26T01:45:03.059Z Has data issue: false hasContentIssue false

20 - IT'S NOT JUST THE CASE

Smalltalk Report, November–December, 1993

Published online by Cambridge University Press:  04 August 2010

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

Summary

Okay, back to tilting at windmills. Sometimes I think people just don't get Smalltalk. Why in the world would you want a grungy old explicit case statement when you have a superior substitute in the polymorphic message? How could you read and write Smalltalk code for enough years to be able to implement new language features and not understand that you didn't need them?

I guess my tights and cape aren't far enough at the back of the closet…

This month's topic is case statements: practical necessity or pernicious contaminant? My interest in the topic comes from several areas at once. SmalltalkAgents has added a form of case statement to their Smalltalk for the Macintosh. CompuServe has hosted a lively discussion of isKindOf: and its relatives. Finally, net news has had a discussion of case statements. What's the deal?

Cutting right to the punch line, I think case statements are an inappropriate holdover from procedural thinking. While vital in procedural languages, their use in object programs is obviated by the much more powerful mechanism of the polymorphic message send. Anytime you find yourself wishing for or using a case statement, you have an opportunity to take advantage of objects instead. The noncase version will yield a more maintainable, more flexible, more readable, and faster solution.

Type
Chapter
Information
Kent Beck's Guide to Better Smalltalk
A Sorted Collection
, pp. 201 - 204
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 [email protected] 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.

  • IT'S NOT JUST THE CASE
  • 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.023
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.

  • IT'S NOT JUST THE CASE
  • 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.023
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.

  • IT'S NOT JUST THE CASE
  • 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.023
Available formats
×