Friday, May 14, 2010

Communication

The other day I came to the realization that what I need to be good at is communication. Sure my programming skills are still important and my ability to right solid code is a must, but if I can not wrap it in a useful and stunning user interface my coding may be in vain. Many times when I am reviewing applications online I spend less then 10 seconds on their website. If it doesn't load quickly and isn't impressive at first glance I move on. How do I make a stunning interface? How can I get people to pause and learn more when they visit my site?

I know that this sounds silly, but it all started when I started working for an Ad Agency in Cincinnati. As a web developer and a backend, server side programmer, I had spent years developing web based applications that typically were targeted at a single browser, internal audience. Now the applications where public facing and the browser or platform was not controlled. I learned very quickly how hard developing UI and cross browser functionality could be. This wasn't necessarily new as I have known of these issues, at least their existence , for a while now. I have been investigating Google Web Toolkit as a way of navigating around some of these issues. GWT does not provide very much in the way of UI components and most of there stuff is very basic. However if someone knows CSS and HTML fairly well then they can enhance and use the basic components to build more sophisticated components that work well across the browsers. I was determined that CSS was a must to know.

Learning CSS I started with this book. Now for the past several months I carry this thing under my arm as a reference when working on website user interfaces.




During this same period of time I was asked to give a couple different presentations. I had been to the No Fluff Just Stuff conferences and seen some really good presenters. I knew that I did not want to give a boring, read from the slide, bullet riddled presentation. How do you create a stunning presentation? Luckily I work with some really smart people that had already turned me on to a book on Zen presentations. I found it at the book store and glanced through it. It gave me some good ideas that boiled down to finding beautiful pictures from stockphoto. There had to be more then that though. I was very much interested in how to communicate using my presentation tools. After all this post is about communication.

I finally found this version of the book by the same author and it gives details starting with the idea of Zen presentations, going through the different type faces, color themes, photo/video techniques etc...



Conclusion is that I need not only to write good code, but I need to articulate my thoughts in narrative form (blog), live (presentation), and finally in my craft as stunning UI.

GWT: Dealing with the MenuBar inside MVP

Okay so I am trying to follow the MVP pattern of having a View interface that hides the details of the implementation. This has worked great up to the point where I need to add a MenuBar. Normally I would use on of the Has.... interfaces as a return value of a method on the view interface. The presenter then simply calls the getSomeAction().addHandler(....) but this doesn't exist for the MenuItem which uses the Command interface to respond to clicks on menus.

My first response was to create a component that encapsulated the Menu inside a control that had one button per menu item. The view interface could register click handlers by using the buttons on the menu and the menu items would simply fire the click() method on the buttons to execute all registered handlers.

Problem: Button.click() doesn't work if you have not added the Button to the DOM. I don't want the buttons in the DOM and it felt like a kluge to have the buttons in the DOM button hidden.

So my solution was to create a simple interface HasCommand that has one method setCommand.


public interface HasCommand{
setCommand(Command command);
}


Then I extended the MenuItem component overriding the 4 public constructors and implementing the new HasCommand interface. Now I simply use the HasCommand interface in my View definition and this makes it so I can sleep at night.

Monday, May 3, 2010

GWT SerializationException


com.google.gwt.user.client.rpc.SerializationException:

Okay this is really a beginners mistake. I was getting a SerializationException today with a GWT RPC call. Remember to make sure that all classes implement Serializable and that the classes all have the default constructors defined as is required by Java serialization.

If you like defining your classes with useful constructors the provide a way of getting the data into the object then a good approach is to make the default constructor private and suppress the unused warnings.



@SuppressWarnings("unused")
private MyClass(){}



This is one of the first attempts at documenting a problem and solution in my blog as an ongoing effort to develop a solutions log. I may need to come back later with some code examples but I want to continue on for now.