Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-swt-dev] Mac OS X Port

 
On Monday,  15, 2002, at 03:13PM, Andre Weinand <weinand@xxxxxxx> wrote:

Hi Andre, 
thanks for your fast reply.
I`ll try to run the examples using the 'SWT_JDK' JRE this evening back at home, where I can work with a decent OS. ;-)
Sorry for the noise, I should have read the readme before I ask stupid questions.

>>2) In order to manage all the different enums and its constants
>>available, shouldn´t we adapt a kind of emulating enums and
>>encapsulate groups of related Items together?
>>A small example:
>>
>>public final class kDataBrowser {
>>	public static final int NoItem = 0;
>>	public static final int TextType = OSType("text");
>>
>>	//...
>>	//... enums don´t have methods!!! ...
>>}
>>This approach could help cleaning up the cluttered OS class.
>>
>>What do you think?
>
>Yes, the DataBrowser's API is large enough that this makes sense.

Being back in my job, I just read "Item 21: Replace enum constructs with classes" in the book "Effective Java" by Joshua Bloch out of Addison-Wesley's Java Series. In this item a "typesafe enum pattern" is described. 
Idea behind "typesafe enum" (from the book "Effective Java"): You define a class representing a single element of the enumerated type, and don`t provide any public constructors. Instead provide "public static final" fields one for each constant in the enumerated type 

Using this everything will get a little more verbose but, the enums will be a lot more _java-like_.
Still there are some some advantages to the "int enum pattern" I thought of in my previous post, one of which is, that you can easily use the int fields in a switch statement.  
So I´m unsure whether to use the "typesafe enum pattern" or the "int enum pattern". Maybe you could aid me in finding the right decision? :-)  

martin


Back to the top