This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
What is the advantage of using a declarative style of UI building?
I am a UI developer and regularly build UIs using Swing, JME and GWT. I have noticed that declarative UIs are sort of favorite with Google. Android has it. So does GWT (GWT did start with swing style API but I suspect, with the UI Binder and the MVP, they are moving towards XML base) As a developer who prefers pure hand coding, I dont really like this. It smells too much of Drag & Drop style UI builders, which in my opinion, is bad news. In my experience, hands on coding facilitates extreme level of control as required.
On this background, one cannot help but wonder, what are the advantages of using declarative style of UIs.
In Android XML based layouts are loaded through a mechanism that could be seen as similar to a java.util.ResourceBundle. The main difference is that in Android the resource loader takes far more than just language into account. Some of the additional parameters that the resource loader takes into account are: time of day, screen size, pixel density, and device orientation. The full list of these attributes is available in the Android Documentation.
For GWT I've found that the XML layout structure makes it easier to work with designers that think and work in HTML, while not sacrificing any of that GWT goodness. That said: I don't see the GWT UIBinder adding as much value to my work as the Android loading mechanism.
In neither of these platforms are you forced to work with the XML layout, but certainly with Android I strongly recommend it. Coding different screens in Java for all the possible device permutations would be a nightmare, take significantly longer, and would also require special handling of changes to the device configuration (language, orientation, etc.).