GeeCON Prague 2014*
The moose likes Android and the fly likes Declarative UIs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Mobile » Android
Bookmark "Declarative UIs" Watch "Declarative UIs" New topic
Author

Declarative UIs

Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10425
    
    8

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.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Jason Brent Morris
author
Greenhorn

Joined: Mar 29, 2011
Posts: 10

Hi there Maneesh,

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.).

Regards,
Jason


Author of: Android User Interface Development
Available Here: http://link.packtpub.com/Uczf1u
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10425
    
    8

Thanks Jason
 
GeeCON Prague 2014
 
subject: Declarative UIs