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.

ConversionHow do you convert information from one object’s format to another’s?Different clients may need the same information presented with different protocol. For example,one object may need to look at a Collection sorted, another with duplicates removed.The simplest solution is to add all of the possible protocol needed to every object that may be askedof it. This might result in unnecessarily large public protocols with the resulting difficulty inpublication and understanding. The same selector might need to mean different things to differentclients, making this approach simply unworkable.When information is needed in several forms, convert from one object to another rather thanoverwhelm any one object’s protocol.Conversions that return objects with similar responsibilities should use a Converter Method. Toconvert to an object with different protocol use a Converter Creation Method.<strong>Coding</strong> <strong>Patterns</strong> page 28 of 147 9/30/2006

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

Saved successfully!

Ooh no, something went wrong!