|
|
||||||||||||||||||||||||||||||||||||
Evan Summers's BlogJune 2008 ArchivesA short history of Web UI programmingPosted by evanx on June 26, 2008 at 07:18 AM | Permalink | Comments (12)Web 1.0, XUL, Ajax, Laszlo, Flex and Silverlight have a common approach - declare the UI view using markup (HTML or XML), and use JavaScript to handle the UI events and manipulate the UI. JavaFX/Swing is a notable exception - which is exciting and/or risky?! 'Cos Web developers know and love JavaScript and HTML, so XML plus JavaScript is right up their alley. If you're a Java UI programmer, there's GWT, Wicket and Echo. And with a great new Java plugin in the works, maybe Swing applets will be considered again in some quarters? But all web developers know JavaScript, and not necessarily Java, Groovy, et al, so probably JavaScript/Swing is a better bet than Java/Swing? Imagine having an XML schema for a flashy JavaFX/Swing toolkit, call it JavaFXml, with great JavaScript bindings, so make that JavaScriptFXml ;)
HTML, CGI, Perl
JavaScript, DHTML
Java Applets
PHP
Java JSPs, Servlets
XUL
Ajax
Laszlo
Flex
Silverlight
JavaFX
Everything from HTML, through to XUL, Ajax, Laszlo, Flex and Silverlight, have a common approach, namely let's declare the UI view using markup (HTML or XML), and use JavaScript to handle the UI events and manipulate the UI.
With a great new Java plugin in the works, and other JavaFX-induced improvements for client-side Java, maybe Java/Swing applets will be the preferred option for many of the Java programmers out there, rather than moving to one of the available scripting languages on the JVM eg. JavaScript, Groovy, JRuby, JPython, JavaFX Script? If we want JavaFX/Swing to succeed in the browser, surely we need a GUI tool to design those flashy UIs, generate XML, and be scriptable using JavaScript first, and otherwise Groovy, Java et al, for programmers that prefer those other JVM languages.
Taking a cue from the cutting-edge of EJB3/Seam programming, last week i wrote an article titled "Gooey MVnC" proposing a convention-over-configuration MVC framework for Swing GUIs - to eliminate boilerplate and glue code for beans binding, events and tasks. Everytime i revise that article, i might write a new blog entry, like this one, just so that i can link to it again, which is precisely the reason why i was inspired to write this blog entry!
MVnC architecture for Swing GUIsPosted by evanx on June 19, 2008 at 06:52 AM | Permalink | Comments (0)Rather than put our "application logic" in a "messy" view class, we create a separate "controller" class, with event handlers. We wish this controller class to be as neat and tidy as possible eg. with minimal boilerplate or much else besides our application logic. Let's explore how we might achieve this, using an annotation-driven application framework, with some AOP and convention-over-configuration.
Please submit your comments and suggestions for discussion below. This is an ideas-in-progress, without an implementation (yet). As such this article should be considered to be a first exploratory draft of a design-in-progress... Next month, i'll whip up some kinda prototype, if it's deemed worth it, and if i'm still unemployed ie. with time on my hands.
Our controller class includes annotations in order to enable our framework infrastructure to automatically map events from our GUI components to event handler methods, and to support background tasks and EDT-switching via AOP.
public class LoginController extends GBasicController { @View LoginView view = new LoginView(); // JPanel with components @FormBean User user = new User(); // for form fields auto binding ... @BackgroundTask void fetchUsers() throws DatabaseException { ... // long running task } @BackgroundTaskDone void fetchUsersDone() { ... // update GUI with results from task } @EventHandler void okActionPerformed() { ... // handle OK button pressed } @EventHander void usernameEntered() throw DataException { ... // validate username exists in database view.password.requestFocusInWindow(); } ... } Annotations in our model beans, eg. User, relate to binding and validation, where we wish to support automatic binding of view components to bean properties, eg. by matching component names to bean property names.
First Class Java: further thoughts on dot notation for class metadataPosted by evanx on June 13, 2008 at 07:42 AM | Permalink | Comments (6)Who knows why i have a dislike for symbols like ->, => and even := ?! It's pathological, i know that, and i have an obsessive-compulsive (dis)order when it comes to code, and so be it.
Now i'm thinking @person.username.property or $person.username.property don't look too bad, although many others suggest person#username of course, citing JavaDoc's notations, which i say is like the tail wagging the dog, but so be it. So what's the big idea? Actually there is no big idea - only a small incremental idea, which is... Let's enable code that is fully toolable, refactorable, et cetera. Which means no references to properties in string literals eg. bind("username", ...). And code that still looks as nice and natural as possible, which to me means using the dot notation as far as possible eg. @company.contactPerson.displayName. Let's imagine some code...
public class LoginController extends BasicController {
LoginView view = new LoginView();
LoginModel model = new LoginModel();
public LoginController() {
bind(view.usernameComponent, @model.username.property);
...
}
...
}
where alternatively, the above might reference the java.reflection.Field literal as @view.usernameComponent.field. This notation eg. @person.username.property actually represents a tuple of the instance plus the PropertyDescriptor, whereas @Person.username.property might literally be the PropertyDescriptor, from which we can get the declaring class ie. Person.class eg. via getReadMethod().getDeclaringClass(). Method's are a bit troublesome 'cos of overloading, in which case one might need to refer to their parameter signature to differentiate them eg. @view.load(Weapon, Ammo).method which i don't like the look of, but so be it. Talking about methods, what about "first class methods", anonymous methods, closures or what-ever. Because people find anonymous classes a bit tedious, and many people are aggrieved that Java hasn't got closures like all other popular languages!? My feeling at this minute is that if, like generics, closures can't be implemented simply, then they shouldn't be implemented at all, if the code examples look almost as unreadable as line noise!?
Anyway, now i must start working on my next blog entry, possibly to be entitled "Elucidating the MVNC™ Architecture for Gooey Tablets."
Where "Gooey" is my codeword for "GUI" and "Tablets" are just tabbed
"applets" - in a GUI container frame with a tabbed pane ala the spreadsheet metaphor.
And MVNC™? Well that's an acrononym for "Messy View, Neat Controller, Trivial Model" which is just plain ol' MVC with some trivial guidelines and simple rules, as to what is messy and what is neat and what is trivial, so...
| ||||||||||||||||||||||||||||||||||||
|
|