All of these samples perform essentially the same task: traverse an array of strings and print each value to stdout. Of course, the C++ example is actually using a vector rather than an array due to the evil nature of C/C++ arrays, but it comes to the same thing. Passing over the differences in syntax between these four languages, what really stands out are the different ways in which the task is performed. C++ and Java are both using iterators, while Ruby and Scala are making use of higher order functions. Ruby and C++ both use lowercase variables separated by underscores, while Java and Scala share the camelCase convention. This is a bit of a trivial example, but it does open the door to a much more interesting discussion: what are these idioms in Scala’s case? Scala is a very new language which has yet to see truly wide-spread adoption. More than that, Scala is fundamentally different from what has come before.
GWT is a framework developed by Google to implement AJAX technology. This framework proposes to develop the GUI entirely from Java. This code is then compiled into Javascript, to be embedded in a web application. GWT is composed of a client part, Javascript, which is the GUI application, it communicates with a server developed in Java. Past the discovery of this excellent framework, a question light in my mind: What are the correct patterns and designs code to implement this framework? Let’s take an example, look at the problems and propose improvements to emerge a coherent design. We have a Toy Project, which consists of a login screen. This example, deliberately simplistic, offers the following GUI:
I have been using Wicket for a while now and I’ve occasionally wondered if GWT provides any kind of advantage over Wicket. Here is a comparison and instead of coding a simple “Hello World” kind of example, here is something a little more complex. Functionality The target functionality is a one-page application that shows data in a single table. Item counts are displayed categorized under multiple “spaces” (workspaces). There is a summary row. The user can click on a space to expand the count of items grouped by status. Some of the tricky parts are: * The number and names of the possible status types can be different for different spaces. * Some of the table cells have to be merged to represent the grouping by space and then by status. * the style / color of the different cells has to be controlled to differentiate the total count from that grouped by status. Let's look at the Java code common to the GWT and Wicket implementations.