Tuesday, August 22, 2006

The Open Source Paradigm Shift

O'Reilly describes the Open Source Paradigm shift that is ongoing...

Jigloo Eclipse Windows Builder?

Building GUIs for rich client apps in Eclipse is not the easiest thing in the world. I'm looking for windows builders comparable to the Net Beans GUI builder.

I am downloading the Jigloo GUI builder which sounds pretty good but that is coming from company who made it.

What about WindowsBuilderPro? This is a commercial product, not free like Jigloo. How is it better?

I'll try both and see for myself...

On the install, Jigloo is very simple and is just like any other Eclipse plugins. Just copy to the features and plugins directories and your done. WindowBuilder on the other hand has you walk through a install wizard which took only a couple minutes to run through. (Make sure you don't have Eclipse running during the install).

WindowsBuilder has several example apps you can try. In 5 minutes of testing this builder I found it very user friendly. I liked the "quick view" feature where without even compiling you can get a feel for how your app will look during runtime. Now on to Jigloo.

After the few minutes I found it easy to create a basic app. Nothing difficult. I liked the two screen (code/app) view that shows the two-way changes so if you edit the GUI the code changes or you edit the code and the GUI changes.

So far they are both comparable products and I'll spend a bit more time using each on an actual application to see which is the better product.

The Set Interface

Here is how this works. Set is an interface that extends the Collections object. HashSet is an instance of "Set". You can't just instantiate the interface. You do this with the concrete HashSet, TreeSet or LinkedHashSet implementations. Each of these handle the Collection differently.

The HashSet doesn't care what sequence the data is in, but will ensure no duplicates are allowed.

The TreeSet will sort the data and keep it in that order and the LinkedHashSet will retain the sortation that it originally was stored in.

Pretty simple eh.

Using the for loop with a colon?

I've gone through the famous Eckel book on "Thinking in Java" and could not find the examples I've seen in various code, using a for loop with : instead of commas.

Here is an example of one:
class EnhancedForDemo {
public static void main(String[] args){
int[] numbers = {1,2,3,4,5,6,7,8,9,10};
for (int item : numbers) {
System.out.println("Count is: " + item);
}
}
}
While writing this entry, I found a site which gives some direction on this, but still I am not totally tracking. Looking for a better description.

This format of the "for" loop is generally called the "enhanced for loop" and is used with arrays and collections.

Enhanced For
The Enhanced For Loop

Looks like this was only released with JDK 5.0. No wonder I couldn't find it in my outdated reference books...

Collection Examples

I am drilling on using collections, specifically the "Set" collection.

Here is an example using a simple Set collection:

import java.util.*;

public class FindDups2 {
public static void main(String[] args) {
Set uniques = new HashSet();
Set dups = new HashSet();

for (String a : args)
if (!uniques.add(a))
dups.add(a);

// Destructive set-difference
uniques.removeAll(dups);

System.out.println("Unique words: " + uniques);
System.out.println("Duplicate words: " + dups);
}
}
The program is called with "java findDups2 (here you would pass the arguments)" The above will return you a list of the Unique words and the duplicate words passed in its arguments.

Based on the above, objects could also be checked for duplicates, or specific members of objects such as id numbers, names, addresses, etc.

Taking mental note of this for future operations...