Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-swt-dev] Re: Subclassing Shell

Thursday, January 8, 2004, 1:01:46 PM, Markus Enzenberger wrote:

> On Thu, 8 Jan 2004, Steve Northover wrote:

>> To really answer this question, you need to describe the cases that 
> make 
>> sense to you.

> for instance, I want to ensure that all my windows get the same 
> application icon, so I make a base class, that derives from Shell and
> sets the image in the constructor.
> From a OO design point of view, there is nothing wrong with that.
> The subclass clearly has a is-a relationship with Shell and since I 
> don't want to make any more assumptions about the derived classes, a 
> wrapper class would be not good, essentially instead of inheriting the 
> whole Shell API, I would have to wrap a huge amount of functions.

>> The technical reaons are that the Shell class was not 
>> designed to be subclassed and is different on different platforms.

> the implementation of Shell is different on different platforms, but not 
> the API. And the implementation (whether it uses Java or JNI) is 
> encapsulated in a class.
> with technical reasons I mean any other reasons than whether it is good 
> or bad software design. Is it a bug if I create a sublass of Shell?
> How could something break or be platform-dependent?

You are definitely well versed in the pros and cons of subclassing vs.
composition.

You are *probably* safe if you override an API method to do something
simple, and then call the superclass version of the method.  But it
was still not designed to guarantee safe subclassing.  The whole thing
is being aware of the risks involved, even if they are small.

-- 
Regards,
David                            
mailto:dlwhiteman@xxxxxxxxxxxxxxx
news://news.eclipse.org/eclipse.platform.swt
http://www.eclipse.org/newsportal/thread.php?group=eclipse.platform.swt



Back to the top