Thursday, February 12, 2004

SWT design question

I just started getting into SWT over the last few days. My exploration took me into the source code where I ran into a confusing pattern. Everyone knows that SWT uses native system calls to render components (when native components are available on the current system). The SWT application asks the SWT libraries for a button and SWT then delegates the work to the operating system.

Here�s the strange part: I figured that a factory would have generated either the button itself, or an internal helper class within the button. The button or the delegate would just need to implement an interface that defines the behavior of a button. That turns out not to be the case. The source code for the Button class has �Windows only� code in it. If you download the source for the Macintosh version of SWT, the same class exists, in the same package, but contains different code!

This is a very high profile project with a lot of good developers working on it, so I know this isn�t just an oversight. I can only assume that it�s a convention handed down from another project or an organization tactic that I�m just not getting. I looked around and haven�t found an explanation. If anyone knows why the eclipse team choose this design, I would love to hear about it.

Labels:

0 Comments:

Post a Comment



<< Home