James Edward Gray II wrote:

> 
> On Wednesday, October 9, 2002, at 05:15  PM, david wrote:
> 
>> just curious:
>> if you want child's functionality, why wouldn't you want to have the
>> child
>> object in the first place?
> 
> Glad, you asked; I would love a second opinion!  My server manages
> vanilla Telnet connections with a Connection object.  All the Telnet
> protocol stuff is in an easily replaced method though, for subclassing.
>   I want to keep it so Telnet is always supported, and thus the default
> connection type.  But connections can be upgraded to a higher protocol,
> if they ask for it.  That's why I thought it would be cool to just
> upgrade the object reference when the request comes in.  Tell me if you
> see chinks in that suit of armor though, I'm all ears.
> 
> James

forgive me if i am wrong but you basically have:

1. a server of some kind
2. this server uses the Connection object(class)
3. the Connection object has a method that handles the Telnet protocol
4. when you subclass Connection, you still want your Connection object to 
still be able to handle the Telnet protocol but also be able to handle the 
protocol that the child class is designed to handle
5. this way your Connection object not only handles the Telnet 
protocal(because it already know that from the beginning) but also the 
child class's protocal(because you upgrade Connection to the child class).

if that's what you want, i really don't see any advantage of doing this.
you are basically making the parent back to the child but the child is 
already a parent! instead of subclassing Connection, i would just decouple 
Connection into 2 separate modules: one for handling the actual Telnet 
protocal(really genertic) and another one for handling connection to the 
Telnet protocal so you will have:

1. a class(call it TelnetPro) for handling the Telnet protocal only.
2. subclass TelnetPro into Connect for handling connection for Telnet

now say that you want to add HTTP support to your server, you will code 
another class(call it HTTPPro) for handling the HTTP protocal and 
subclass(yes, multiple inheritence) Connect from it again. hopefully all 
you have to change is one line in Connect from:

@ISA=qw(Exporter TelnetPro);

to:

@ISA=qw(Exporter TelnetPro HTTPPro);

all the sudden, Connect knows how to handle Telnet as well as HTTP. as you 
add more and more protocal support, you will keep adding to Connect's @ISA 
to support those.

this might not work depends on the actual spec and requirment of the project 
that you are working on. just my 2cent :-)

david

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to