Will be attending this year’s QCon in London

From the 11th to14th of March this year I will be visiting London to participate in QCon 2008. It will be my first QCon but I have high expectations. First of all the organization of the event is done by InfoQ which is a well known and valuable source of information on enterprise software, and by the JAOO people, which organize some of the coolest conferences on software technology. Also the list of speakers is quite impressive, for example you have people like M. Fowler, Erich Gamma, Kent Beck, Rod Johnson, Neal Gafter and many others that are the crème de la crème of software engineering. Finally I’ve found many sessions that I would like to participate in so I guess I’ll have 3 days packed with presentations.

If you are also participating in QCon 2008, feel free to drop me a line or contact me directly at the venue.

tags: qcon, qcon2008, qconlondon

The Way of Client-Side Templating

templating.jpgIt is generally accepted that in every field of IT where a UI is needed there is great benefit from the separation between the content and the presentation rules. To quote Martin Fowler from his book “Patterns of Enterprise Application Architecture”: ”the separation of presentation from model is one of the most fundamental heuristics of good software design”. Especially in the area of web development this is somewhat of a holy grail, where every new framework or architecture claims that it has managed to split these two different considerations in a way so much better than everybody else.

So, how would you go about separating these Siamese twins? One of the usual ways people strive to achieve this is by trying to make the best of the MVC architectural pattern. It is common to split an application into separate layers: presentation (UI), domain logic, and data access. The MVC patterns that was originally intended for Smalltalk goes further by additionally separating the presentation layer into View and Controller. The View in particular renders the model into a form suitable for interaction, typically a user interface element.

The View layer classically implements a templating mechanism where content is assigned to a template and a template rendering engine performs the necessary transformations for the display. Although the use of a templating engine is not required, it has several benefits. First of all it provides a well-defined formalism for the effective separation between content and presentation. Also because the whole concept is based on a loosely-coupled relationship between engine and templates, it promotes reusability and ensures easier refactorings. Another important benefit is also the fact that it encourages the divisions of labor, where different people are assigned the user interface and others the domain logic.

It might not be clear to many developers, especially to younger ones, but the above reasons where the fundamental motive we came up with technologies like JSP, PHP and ASP. All these web development languages are basically template languages and where conceived in order to separate program logic from HTML markup. The first time I came in contact with this kind of languages was 9 years ago during the break from a Lotus Notes training and I can still remember how revolutionary JHTML looked for someone coming from the CGI world, like me.

In the case of web applications where the UI is the browser that renders the HTML, the dominant paradigm is for the templating component to exist server-side. In this post we are going to be dealing with the presentation logic that sits between the domain logic and the pure layout and design logic that is handled by CSS rules that manage colors, sizes, fonts and positions. Although you can do many things to manipulate the presentation with CSS its power is restricted due to the limitations of the CSS implementations and is beyond the scope of this article.

In the Java world the most popular templating solution is Tiles by the Apache Software Foundation. It allows authors to define page fragments which can be assembled into a complete page at runtime. These fragments, or tiles, can be used as simple includes in order to reduce the duplication of common page elements or embedded within other tiles to develop a series of reusable templates. These templates streamline the development of a consistent look and feel across an entire application. Tiles in conjunction with Struts have been the default solution for Java web developers for the last years.

On the other side of the river, in the PHP realm, Smarty has been the dominant templating framework, that provides the programmer and template designer with nice tools to automate tasks commonly dealt with at the presentation layer of an application. Another one is PHPTAL which implements the Zope Page Templates syntax. This is my personal favorite because it works on XML attributes instead of markup tags so you can use it to insert dummy content in places where for example you get data form a DB. In this way you can view your templates in a WYSIWYG editor like Dreamweaver. Although the implementation differs from Tiles, the basic pattern for all these engines is the same: do the templating server-side.

When talking about templating it is important to mention the Composite View pattern. This is one pattern that is commonly used by templating engines to assemble a web page from several components. To quote the Core J2EE Pattern’s Catalog: “Use composite views that are composed of multiple atomic subviews. Each component of the template may be included dynamically into the whole and the layout of the page may be managed independently of the content.” This functionality is quite common in portals where individual parts of a page are different components with diverse sources and caching settings that are assembled in a flat page (or hierarchies). The benefits of having pluggable and reusable components are obvious. The Composite View pattern is based on the GoF Composite pattern which composes objects into tree structures to represent part-whole hierarchies.

Although in the early days of the Web the browsers where just dumb markup renderers, with the emergence of Firefox 2 and IE 7 they have come to a point where the application developer can rely on the client side for several functions. JavaScript implementations still have many incompatibilities but you can count on them to perform many complex tasks as asynchronous access to remote resources (XHR) and generations of multifaceted markup. Also many frameworks like Dojo, jQuery and Prototype have emerged that assist the development of intricate OO applications that under the hood leverage patterns and best practices. Finally the browsers pack several other components that are exposed through simple APIs like their XSLT engines.

All the above reasons are strong enough to make us consider moving a greater part of our application to the client-side. Since the presentation logic is the closest layer, it comes natural to reflect on if it would be reasonable to move it to the browser and also the various ways that this could be achieved.

Having the presentation – templating logic in the client-side has several great benefits:

First of all you get the ultimate division of labour since the presentation is not only in a different language/technology than the rest of your application but it is not even located in the server. The people responsible for it might not even have access to the server.

The high degree of separation that is innate of this paradigm has the result of producing highly decoupled architectures. Besides the flexibility that the decoupling brings, it is obvious that it promotes testability and makes for easier refactorings.

Since the various components will be downloaded in the form of XML, JSON, YAML and will be assembled at the client-side (for example in the manner of Composite View Patterns) we can benefit from the various network caching mechanisms. Our “content components“ may be cached by proxies or even at the browsers. Imagine a portal page that consists of 10-12 different parts (components). When you visit another page most of them will not change and are already in your cache. In this way you save bandwidth both for the client and the server since for a busy portal the bandwidth cost per byte is a significant factor. Hell, with smaller network traffic you can even save the planet!

Another advantage would be that by distributing the template processing functionality to the clients you improve the scalability especially in installations with elaborate templating mechanisms. Maybe the presentation layer is not the usual place where you need to optimize for resources like in the case of DB connections or the memory management, but the various aspects of templating, like markup transformations and caching consume an important amount of system resources. By putting the load to the client you can save not only in bandwidth, as we saw in the previous paragraph, but also in CPU, memory and disk space.

Client-side templating is not something new. Actually it has been described as the Browser-Side Templating pattern in the Ajax Patterns Catalog. Although it is not the dominant paradigm, I feel that as browsers mature in terms of JavaScript engines and XSLT processing, it has the potential to become ubiquitous. Maybe even a buzzword 🙂

When I originally planned on writing this post, I had in mind to write a little code to demonstrate the concepts. Unfortunately due to the verbosity of markup code, the limited nature of a blog post and the several approaches the you can choose from, I believe that I wouldn’t be doing justice to the whole concept by just giving out a couple of short examples. If you are interested I would suggested you visited the online demo of JST and checked out an example of browser-side XSLT.

JST and XSLT and several other technologies are tools that can be used to develop client-side templating functionality. These tools are powerful and flexible enough in order to be combined together in various ways to provide for different deployment strategies. For example you might find that your application may well benefit from using the Two Step View pattern which basically transforms content to markup not in a single step, but in two. Or you could use more steps if you have well-defined natural hierarchies in your domain model. Also you might find that your architecture calls for the use of the View Helper pattern for handling logic that is part of the application but it is too complex to fit in the actual template.

Whatever you choose, there are several factors to consider before moving to client-side templating. In most cases these disadvantages are not prohibiting. It is important though to have them in mind since they might become a problem in some corner-cases.

In particular:

  • Although the frameworks provide us with abstractions that are portable, nobody guarantees that they are 100% portable
  • Client-side
    frameworks tend to be harder to debug. It is especially difficult for developers
    that are accustomed to strongly-typed languages like Java or C#, to try to
    debug JavaScript.
  • XSL has its roots in DSSSL which in turn is a subset of Scheme which is a dialect of Lisp. Therefore, mastering this language for someone coming from a procedural or OO background is a slow and painful procedure (but very useful).
  • Companies like Sun or Microsoft still push for their traditional server-side templating solutions so there is no major support or tooling.

Report from the “Java Developer Day 2008” in Athens

For the second year in a row the “Java Developer Day” was held in Athens Information Technology (AIT), where the familiar team of Java Evangelists informed the Greek community about the latest and greatest from the world of Java.

The venue was very good, although packed and some people had to stand up, at least at the first 2-3 presentations. I was happy to see many familiar faces and meet friends that I never knew they were attending. Maybe because 3/4 of the participants were from the NTUA.

javatechday2008_nokia_037.jpg

The organizers had prepared a comfortable environment in which you could listen to the presentations, get together with colleagues and share opinions with new people. After all one the great thing about these kind of events is that you not only have the opportunity to hear from the experts but also network with people from your own geographical region that share the same interest with you: Java 🙂

javatechday2008_nokia_025.jpg

Of course there were some issues that might need to be addressed for future similar events like the fact that:

  1. The location was outside of the city and getting there was hard. I suppose if it was held somewhere closer to the center the attendance would have been much (!) greater.
  2. There was no Wi-Fi in the auditorium. If you are going to hold an event from 9am till 5pm you have to give the participants some way to communicate with the outside world and their work. UPDATE: Aris informed me that there was a wireless internet access point in the auditorium and several people used it, but I didn’t hear it when they announced it.
  3. Since the schedule was packed there were no questions after each presentation. Don’t get me wrong, I like the fact that there was time to mention all these different and sometimes diverse subjects, but the interaction with the audience is a big part of the experience in similar events.

Since I have organized several events in the past I understand the many difficulties that characterize similar endeavors and I have to say that both this year and the last year, the organizations from Sun Microsystems Greece deserves two thumbs up!

A small outline of the event (as I witnessed it) follows. The structure you see is about how I as a participant perceived each presentation and doesn’t necessarily represent the actual structure of every single presentation.

So here it goes:

Welcome by Aris Pantazopoulos

Although I was a bit late and I missed the beginning it felt like a warm welcome that set the mood and the pace for the rest of the event.

“About AIT” by AIT Vice Chair

I didn’t get the name but I was surprised in a positive way to see the Vice Rector of AIT. He was much younger than what you would expect from a person in such a position, but I feel that for technological academic institutions it is crucial to tap in the energy and fresh ideas that younger people have. Many time the problems in this country come from people that have delayed their retirement for longer than they should have (…)

As for the actual presentation of AIT, it was quite impressive and will probably make several people consider it as an option for their postgraduate studies in Greece.

“View from the top” by Reginald Hutcherson

Regi is a very engaging speaker! He really makes you involved in the subject. He has visited our country on several occasions and as I learned there is a chance he’s coming back soon for a Solaris event.

javatechday2008_nokia_039.jpg

Basically this presentation was about Sun’s software strategy:

  • Business realities
    • A global internet economy
    • Massive scale
    • Demand for enormous throughput
    • Even more demand for flexibility
    • The world was never so inter-connected
    • We have free media
    • As well as free software
    • And free services
    • He introduced the term “Webolution” (a bit tacky for my taste but…)
  • Dynamic Languages = Productivity (Sun finally realizes that – better late than never)
  • New opportunities
    • New services
    • New products
    • A new mass market
  • JRuby
    • Sun came late to this game as opposed to M$ that has been supporting dynamic languages in its VM for a long time now – they have even rolled out a functional language on top of their CLR – F#. So since Sun joined late they are a bit more eager to “play”, hence the many times, unrealistic value that they place on Ruby.
  • Ajax for the next generation of web apps
  • JavaFX (more will follow on that)
  • JavaFX mobile (again more will follow)
  • The VM: a virtual machine of languages, not only Java
  • NetBeans 6
  • Solaris with emphasis on its many system virtualization solutions
  • Open Source Java
    • About a year old
    • OpenJDK: An open source JDK!
    • Will be adding closures (now there is a controversial topic!)
  • Java 7 (looking forward)
  • The GlassFish Application Server
  • JavaME: Will be superseded by JavaFX or merged with it, but it will be probably still be supported for some time
  • Java User Groups

“Secrets of concurrency” by Dr. Heinz Kabutz

Heinz is a Java Champion living in Greece. He consults, holds courses, programs, and writes a weekly newsletter in which he shares some rather unconventional insights about Java. Things that push the envelope; make Java do things you thought it could not; dirty tricks and such. In other words, stuff you do not usually find in Java periodicals or newsletters.

You can find his newsletter at: http://www.javaspecialists.co.za/

javatechday2008_nokia_030.jpg

Heinz suggested that writing multithreaded code will become more customary as multi-cored processors become ubiquitous.

Also informed us about a special course he is offering for Greek Residents only. It will have a 50% off discount and it will be named something like “Greek Geeks Masters Course” or something similar. It sounds interesting and you can find more info on http://www.javaspecialists.eu/courses/master.jsp

Heinz proceeded with his classification of typical concurrency issues into laws – “The Laws of Concurrency”. I will only give out their names without getting into a great detail since you can get this information from his newsletter. The names are actually quite intuitive:

The Law of:

  1. …Sabotaged Doorbell
  2. …Distracted Spear fisherman
  3. …Overstocked Haberdashery
  4. …Blind Spot
  5. …Leaked Memo
  6. …Corrupt Politician
  7. …Micromanager
  8. …Greek Driving (!)
  9. …Sudden Riches
  10. …Uneaten Spinach

“Java SE – Today and Tomorrow” by Simon Ritter

Simon had a cold and apologized for his voice but actually his British accent and tone was clearer that 90% of the speakers I’ve heard in my life.

javatechday2008_nokia_031.jpg
  • The Java Language characteristics
  • Community based (ok, not from the start maybe, but Sun has followed the stream)
  • Java SE features
    • On the desktop: Vista look ‘n’ feel, sub-pixel font rendering, splash screens, tray icon, java.awt.Desktop
    • Web Services become easier with JAX-WS and NetBeans
    • Added more scripting support
    • Pluggable Annotations API
    • jconsole improvements
    • Pre-verification for class file updates
    • Many minor improvements like classpath wildcard, java compiler interface, console API and more…
    • Short intro on the basic concepts of the Consumer JRE
    • Proposed features of Java SE 7
      • Closures for Java: Simon tried to give an explanation on closures with artifacts from the Java ecology, but IMHO this is not a good way to explain closures. You need to enter the world of dynamic languages where this paradigm is heavily used, for example talk about closures in JavaScript.
      • Auto-generated getters and setter with the property keyword. Again this is a feature that comes from dynamic languages and for example is heavily used in PHP with __get() and __set().
      • Swing Application Framework to simplify Swing development
      • Bean binding (check out JSP 295)
      • Separate parts compilation that supports compilation against an interface and not actually needing a concrete implementation.
      • Super packages for sharing code in a more scalable way
      • Changes to the VM to support dynamic languages

“Ruby, JRuby & Rails” by Dr. Doris Chen

javatechday2008_nokia_032.jpg

My friend Panagiotis has pointed out and interesting post that is introduced as a “fair and balanced” look at the static vs. dynamic typing schism. Reading this is a prerequisite in order to understand how much of the faith that Sun puts in Ruby (and other dynamic languages) is justified and how much is hype. While I like dynamic languages and I code in them almost every single day, you should know that they were not invented yesterday and there are several things you have to consider when you are comparing them with Java. There has been much ”static vs. dynamic” debate on the web. You even have guys from Ruby debating on why the strong dynamic typing of their language is so much better than the weak dynamic typing of languages like PHP or JavaScript. For the later two languages, as far as I know in the new versions there are suggestions to include optional type declarations.

So Doris (with an exotic accent):

UPDATE: A reader pointed out that the link to the “orthodox” blog in 15’ demo linked to a RoR webcast and not to the actual NetBeans demo that Doris demonstrated. The reason I used the characterization “orthodox” and pointed to this link was because since the RoR team posted that exact webcast (“How to build a Blog in 15’”) some years ago, every framework developer in the world has made it his mission to copy this demo and apply it to his own language/framework. It has been used so much that it has become a cliché, to the point that people have created parodies like the one by B.V. Puttyngton: “SQL on Rails: Creating a search engine in 8’”. Besides the fact that it is not intuitive anymore, it fails to deal with many of the interesting aspects of RoR and even worst hides under the carpet, the many limitations. For example the Active Record Pattern and the respectful implementation from the RoR team is only one way to go when choosing an ORM solution. It is usually the choice of lighter frameworks like the ones build with dynamic languages like Ruby, PHP etc. This approach has its strengths and its limitations and someone should study this pattern  as well as the Data Mapper pattern which is a more heavy-weight approach. A discussion about data access patterns is beyond the scope of this article. Finally I would like to mention that a presentation of a dynamic language to an audience coming from a statically-typed background is extremely difficult and would probably require at least a day. Doris is an appealing speaker but she had an impossible task. Stuff like dynamic typing, higher-order functions, object runtime alteration, closures even continuations are not only new to most java developers but alien! I could almost sense the difficulty that Simon had (in another presentation) when trying to explain closures using artifacts from the Java space. If there was one person in the audience that got closures with the example of inner classes he deserved a t-shirt 🙂

Ta-daaaa: Lunch Break

Excellent, both in quality and quantity.

“JavaFX” by Simon Ritter

  • Basic Idea: Scripting an application for cross-platform deployment. Even though Java is innately all about that, JavaFX tries to make it a little bit simpler.
  • The original name was F3 = “Form Follows Function”
  • Language Basics
    • OO, declarative, statically-typed, automatic data-binding, etc.
  • Tooling with NetBeans and Eclipse
  • The “Ugly Java GUI Stereotype”: Essentially GUIs with AWT or Swing are not aesthetically pleasing
  • May try to extend basic AWT/Swing with Java 2D
  • Gave some hints on the syntax:
    • Variable declarations
    • Functions
    • Operations (procedures) which are almost like functions but (if I got it right) if you bind to an operation it binds once and won’t be updated (as in the case of binding to a function).
    • Arrays (only one dimension!)
    • Expressions: very similar to Java’s; a double for-loop (nice!)
    • do-block: for avoiding the Swing blocking
    • Classes
    • Attributes
    • Triggers
  • JavaFX Widget usage
  • Animation with the dur operator
  • Direct DB access with JDBC or direct calls to enterprise components (maybe even calls to remote services?)
  • Script deployment:
    • The runtime is a 1,5MB jar
    • Can be deployed as a standalone java application (jar), applet, with Java Web Start
  • Future of JavaFX
    • A (native?) script compiler
    • More tooling
    • Integration with the consumer JRE
    • Mobile device’s support
  • The Consumer JRE
    • Quick starter
    • Deployment toolkit
    • Installer improvements
    • Graphics performance
    • New cross-platform look ‘n’ feel
  • Demos
    • Basic shapes, rotation, transparencies, etc.

If you have checked out JavaFX in the past and have though that it seems similar to Adobe’s Flash/Flex stack well… you were right: it is competing with the later stack in a direct way. While Abode has a lead start, I feel that with the native power of the Java platform, JavaFX has the potential to easily outshine Flash/Flex (and Silverlight)!

“Java developer @ Work” by Paris Paris Apostolopoulos

Paris is the leader of the Hellenic Java User Group (JHUG) in Athens, Greece. He has been working in a series of JUG-sponsored developer events held in Athens to build-up the Java developer community in Greece.

javatechday2008_nokia_036.jpg

Paris gave a talk that aimed mostly on junior developers and contained valuable information that when I started out, I had to try really hard and make many mistakes in the process in order to attain it.

In summary:

  • “What makes a good developer?”
  • The “Passion” of development
  • Staying up to date
  • Top Java Publishers
  • Java News Sites
  • Other Useful Resources: tutorials, blogs, etc.
  • Tools: IDEs, build tools, quality tools, testing, versioning

You can find the slides from his presentation here.

“Solaris & OpenSolaris” by Simon Ritter

Simon is quite appealing as a presenter but OSs is not really my field so I had an early coffee break 🙂

“Java EE & GlassFish” by Dr. Doris Chen

  • Java EE Overview: Differences from J2EE 1.4 like POJOs, annotations, dependency injection, etc.
  • Spec changes
  • An example of how “easier” are web services with JAX-WS than they were with JAX-RPC
  • How easier are EJB references with resource injection
  • JAXB 1.0 -> 2.0 (less LOC)
  • GlassFish:
    • A Java EE 5 compliant Application Server
    • Open Source License (choose from CDDL or GPLv2)
    • Strong community
    • Time line: v3 2008/2009
    • Showed a diagram of the GlassFish ecosystem
    • Mentioned some adoption stories
    • Main features: the Metro stack, clustering, JBI (OpenESb 2.0), Performance (…), etc.
    • Ajax Support: jMaki, DynaFaces, JRuby
    • jMaki demo with NetBeans.
  • Grizzly
    • Uses NIO primitives
    • Non-blocking sockets to the HTTP processing layer (!!!)
    • Some benchmarks (…)
    • Demo with Comet: A Flikcr-based chat
  • GlassFish v3:

“Sun SPOTs” by Simon Ritter

  • What is a a Sun SPOT: basically a little device running some sort of Java and supporting some kind of wireless network

Sorry Simon but at this time I had to leave so I missed the virtual-glove-minority-report-style demo which gets the crowd going…

Epilogue

Finishing up I would like to thank all the people that worked to make this event possible. Even though they make it look simple because they are talented, it is quite hard.

Having said that, I’d also like to see more efforts like that from Sun and even events that go beyond basic introductions and delve into the inner-workings of specific technologies. Events more focused on senior developers that have further technical depth.

At the time of this writing the only open Java events I have participated in Greece and where focused on more experienced developers were events organized by the JHUG.

Facebook stats for Greece

My friend Panagiotis pointed out this interesting post about how you could use the Facebook’s online ad builder interface to get all sorts of interesting statistics.

Since I have a couple of hours until my movie begins I thought it’d check out some numbers regarding the adoption of Facebook in Greece. It feels like everybody you know is in Facebook nowadays so lets see:

There are 183,840 Greeks from which the 56,060 are males, the 57,560 are females (almost 50/50) and the rest haven’t specified their sex.

There are only 40 minors and about 1,740 that have stated that are over 60 years old (!)

While trying to get some work related info I came to conclusion that most of my compatriots are reluctant to enter details about where they work. There is really not that much data. A similar tool for LinkedIn would have been much more interesting.

Finally, since we all know that many people use Facebook for dating/flirting, it interesting to see that only 28,040 members have stated that they are single and 30,920 have said that they are in some kind of relationship or have a more formal commitment. Again the majority is reluctant to give out private information. Little do they know…