13.07.2015 Views

Smalltalk Best Practice Patterns Volume 1: Coding - Free

Smalltalk Best Practice Patterns Volume 1: Coding - Free

Smalltalk Best Practice Patterns Volume 1: Coding - Free

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CollectionsThe collection hierarchy is one of the great strengths of <strong>Smalltalk</strong>. Code that has to be tediouslywritten over and over in other languages is a single word in <strong>Smalltalk</strong>. The result is more flexible,because the collections respond to much of the same protocol, so a linear list and be converted to ahash table by substituting “Set” for “OrderedCollection”.The bad news is the collection classes give you yet more stuff to learn so you can master <strong>Smalltalk</strong>.The good new is no single piece of the protocol is complicated or hard to learn and the result iscode that is simpler, faster, easier to maintain, and more flexible.The very richness of the collection classes is there biggest drawback. Beginning programmerstypically learn to use a small fraction of the available classes and messages, relying on leftoverskills from procedural programming for the rest of the functionality they need. As a result, theircode is much larger than it needs to be, difficult to read for an experienced <strong>Smalltalk</strong>er, and moreprone to error.For example, it is common to find hand coded loops for iteration in beginner <strong>Smalltalk</strong> code. Notonly is:| index |index := 1.[index

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!