help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-smalltalk] Iliad - asResponse implementation


From: Stefan Schmiedl
Subject: [Help-smalltalk] Iliad - asResponse implementation
Date: Sun, 21 Jun 2009 16:27:07 +0200

While looking around in Iliad source code, I noticed that
Object>>asResponse is implemented using Object>>printString.

Dolphin Smalltalk makes a -- quite useful -- distinction
between

  printString   - what the developer wants to see
  displayString - what the user gets to see

Since we're living in a console based environment, I guess
that printString gets exercised quite a lot there.

So here's my question: How about

Object extend [
    asResponse [
        <category: 'converting'>
        ^Iliad.Response ok
            nextPutAll: self displayString;
            yourself
    ]
]

Also, I'm seeing that Iliad.Response supports the "usual"
streaming methods #nextPut: and #nextPutAll. What about

Object extend [
    asResponse [
        | response |
        <category: 'converting'>
        response := Iliad.Response ok.
        self respondOn: response.
        ^response
    ]
    respondOn: aResponse [
        <category: 'responding'>
        self displayOn: aResponse.
    ]
]

I think that this approach could avoid (repeatedly) building
and printing strings. And it would offer a non-intrusive
new method #respondOn: to override in subclasses. So I could
eat my cake and keep it, too: 
printOn: for console work, 
displayOn: for (possibly embedded) content representation,
respondOn: for responding the object

Note that I'm just venting hot air, as I have yet to write
my first line of Iliad-related code .-)

s.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]