Jaaved Ali Khan

16%
Flag icon
I avoid the protocol explosion problem by only representing conversions with a message to the object to be converted when: • The source and destination of conversion share the same protocol. • There is only one reasonable way to implement the conversion. • Provide a method in the object to be converted that converts to the new object. Name the method by prepending “as” to the class of the object returned. Here are some examples. Notice that the object returned has the same protocol as the receiver (Sets act like Collections, Floats act like Numbers). Collection>>asSet Number>>asFloat
Smalltalk Best Practice Patterns
Rate this book
Clear rating
Open Preview