Squeak VM, real-time I/O, and threading
Stephen Pair
spair at advantive.com
Wed Jan 30 18:31:52 UTC 2002
I agree with Goran completely on this issue. Subclassing is
particularly in-appropriate for network protocols, since they should be
stackable. For example, Http could be implemented by stacking the
following:
HttpServer
SocketStream
Socket
HttpClient
SocketStream
Socket
So, an HttpClient would hold onto an a read/write stream of some sort (a
SocketStream if you're doing Http over TCP). The stream (a SocketStream
in this case) would hold onto a Socket. No subclassing.
If it were done carefully, you could even stack another protocol on top
of Http:
InstantMessageClient
HttpClientReadWriteStreamAdaptor
HttpClient
SocketStream
Socket
InstantMessageServer
HttpServerReadWriteStreamAdaptor
HttpClient
SocketStream
Socket
- Stephen
goran.hultgren at bluefish.se wrote:
> Hi!
>
> I wrote:
> > >>1. I personally don't like the added
> > >>methods in Boolean like
> > >>#yourselfUnlessFalseDoFirst: . I
> > >>had to stare and check and think
> > >>and almost still didn't get it! ;-) My
> > >>advice: Get rid of those. :-)
> > >
> > > Hmm, they seemed straightforward and useful to me at
> the time. :)
> > > I'll take another look...
>
> > I'm glad this is mentioned. I forgot to tell you about this
> before. I
> > removed those methods from my image a long time ago :)
>
> :-)
>
> > >>The Client/Server classes built for
> > >>reuse by inheritance would be
> > >>easier to use, I think, if
> > >>constructed for reuse by
> > >>composition.
> >
> > Goran, what do you mean? Can you think on any example with
> a concrete
> > protocol (FTP, TFTP, SMTP, whatever)?
>
> Well, I mean that the classes "Server" and "Client" are meant
> to be used by subclassing instead of using them as
> "instances" (they would probably need other names then).
>
> Often OO code uses inheritance too much IMHO. Reusing code by
> inheritance is much more brittle than reusing by composition
> and it often requires the developer to study the source of
> the superclass instead of relying on a good external protocol.
>
> regards, Göran
>
More information about the Squeak-dev
mailing list
|