[squeak-dev] Object>>printOn: refined.

Trygve Reenskaug trygver at ifi.uio.no
Thu Jun 4 05:54:39 UTC 2020


Great! So I'm not the only one believing that object orientation is 
about objects. In Smalltalk, an object is an instance of a class. In 
IoT, an object stands for a Thing. The same conceptual model applies to 
both. Remember Alan Kay's definition of object orientation:

    /Thus its semantics are a bit like having thousands and thousands of
    computers all hooked together by a very fast network. Questions of
    concrete representation can thus be postponed almost indefinitely
    because we are mainly concerned that the computers behave
    appropriately, and are interested in particular strategies only if
    the results are off or come back too slowly./


On 2020.06.03 05:15, Chris Muller wrote:
> Hi Trygve,
>
> Of all the attributes that objects print, I find the "type" (class) to 
> be one of the least interesting.  It's usually already obvious in its 
> contextual usage.  Indeed, it is the "identity" that I, too, 
> am interested in seeing printed.  My solution since 2006 has been an 
> override of #printOn: that adds a one-line dispatch to 
> #printIdentificationOn:.  I then take care in my 
> #printIdentificationOn: implementations to keep the printing as terse 
> as it can be, and sans any line endings, to serve this seemingly 
> recurring use-case I have of wanting a "short version" of an object's 
> string.  For example, when printing the elements of a collection.  
> Having entire domain hierarchies exclude the type entirely from their 
> printString's has been a fantastic experience.  Seeing just their 
> identifications removes a level of formality that seems to foster a 
> better UI "connection" to the objects.
>
> Regards,
>   Chris
>
> On Tue, Jun 2, 2020 at 7:10 AM Trygve Reenskaug <trygver at ifi.uio.no 
> <mailto:trygver at ifi.uio.no>> wrote:
>
>     I find it frustrating to open 3 inspectors on different objects,
>     all of them titled 'aString' (or whatever),
>     IMO, it is much better to open them on the 3 objects: [1234]
>     aString, [3456] a String, [4567 a String.
>     The numbers in square brackets stand for the objects /oop/,
>     actually its /identityHash/. They can be a 7-digit numbers; much
>     too long for my short-time memory to hold many of them. I
>     therefore truncate the number to 4 digits, accepting that I may,
>     in rare cases, get 2 objects with the same identifier.
>
>     I'm running 'Squeak5.3'.
>
>         *Object>>printOn: aStream*
>                 "Append to the argument, aStream, a sequence of
>         characters that identifies the receiver."
>                 " The previous version identified the class, not the
>         instance "
>                 " This new version identifies the instance with its oop. "
>                 " I arbitrarily truncate the oop to 4 digits to
>         simplify reading. "
>
>                 | title |
>                 title := self class name.
>                 aStream
>                     nextPutAll: '[' , (self asOop printString
>         truncateTo: 4) , ']' ;
>                     nextPutAll: (title first isVowel ifTrue: ['an ']
>         ifFalse: ['a ']);
>                     nextPutAll: title
>
>     Enjoy
>     --Trygve
>     -- 
>
>     /The essence of object orientation is that objects collaborateto
>     achieve a goal. /
>     Trygve Reenskaug mailto: trygver at ifi.uio.no
>     <mailto:%20trygver at ifi.uio.no>
>     Morgedalsvn. 5A http://folk.uio.no/trygver/
>     N-0378 Oslo http://fullOO.info
>     Norway                     Tel: (+47) 468 58 625
>
>
>

-- 

/The essence of object orientation is that objects collaborateto achieve 
a goal. /
Trygve Reenskaug mailto: trygver at ifi.uio.no <mailto:%20trygver at ifi.uio.no>
Morgedalsvn. 5A http://folk.uio.no/trygver/
N-0378 Oslo http://fullOO.info
Norway                     Tel: (+47) 468 58 625

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20200604/d3349a7e/attachment-0001.html>


More information about the Squeak-dev mailing list