Friday, 13 August 2010

Creating a multiple page GWT app

I've been playing with GWt for a little while in my spare time. Just expanding the stockwatcher tutorial I talked about before. and experimenting with a few ideas. I've been wondering for a while how to link up multiple pages and start building a more complex app.

Well, I I've just figured out the way that works for me. Thought I'd post it for any one else that's confused. I'll start by taking you through the journey that led me here.

First I had to accept that GWT is about building Advanced AJAX based applications. Just like desktop applications you only get one entry point. So how do you navigate around? Turns out GWT has an Anchor tag and you can easily assign click events to it.

A quick test later and I found that the simplest solution was to create a new load method for the page I wanted to create. Whether I create a new class or not is not the point. I just wanted to prove I could control the onscreen components and use the underlying divs much like a canvas to paint on. I found that I could clear the canvas using RootPanel.get("root div name").clear().

ok, so hopefully it's becoming clearer. To put this example together I've included code snippets that hopefully explain this in much more detail. I've only included the key details assuming you've filled in the other aspects like creating a proper loadPage method. I've just been using that from the stockwatcher tutorial for simplicity

//instantiate the link
private Anchor prototypeLink = new Anchor("Prototype");


// append link to a display panel and assign a click event.
loadPage(){ 
   prototypeLink.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) {         
       loadPrototype(); } 
   }); 
   .....

   mainPanel.add(prototypeLink);

}


 // Then create the destination method and see what we can change
protected void loadPrototype() { 
   // clear the app name
   RootPanel.get("appTitle").clear();
  // add a new app name
   RootPanel.get("appTitle").add(new Label("Prototype")); 


   // clear the canvas
   RootPanel.get("activityList").clear()

   // add a panel
   RootPanel.get("activityList").add(currentActivityFlexTable);
}


The point of all this is that I learnt that I can clear the canvas. So I can paint and clear it at will. I can also therefore keep multiple views loaded but only display them when necessary. That's my assumption any way.


Just hope this helps.

Wednesday, 4 August 2010

Does the human body crave the foods it requires?

CravingImage by ex.libris via Flickr

I just found a post I really had to comment on. Couldn't find a way to link it back here so just thought I'd do it myself. The question was Does the human body crave the foods it requires?

Good point I thought. So I went on a little tirade that I want to keep for posterity. Hopefully it puts my thoughts into a succinct couple of paragraphs.

Everything I see and learn reinforces my view that we are built, just like all other animals, to survive. So our genes will play some part in telling us what to eat but I feel we just learn a lot very quickly when we're young.
We copy everyone around us. We put worms and dirt in our mouths and our parents scold us. Babies will try just 
anything. Parents just protect them from the dangerous stuff. All this experience becomes part of us because it trains our systems, nervous, emotional, physical and the rest of it.
When we're sick cos we ate something bad our bodies are designed to associate it with what made us sick. that's our evolutionary response and in our DNA. We're different to animals in that we override this. Rats undernourished naturally chose food that replaced lost nutrients, humans don't. alcoholics have cronic vitamin defficiency but don't fix it.
So I'd argue that humans are ruled by their minds and emotions far more than animals. We actually learn to ignore our natural instincts infavour of cultural norms and personal preferences.

So, yes I think we genuinely can detect what's in our food, and eat appropriate foods to get the right balance. I just think our lifestyles encourage us to ignore this and we don't really learn how to listen. 

Enhanced by Zemanta

Tuesday, 3 August 2010

Google and Apple are both winning in the mobile markets, they just have different goals

Android Eats AppleImage by Jan Tik via Flickr
I just felt I'd put a few comments together that have been bugging me for a little while.

Firstly that while we're seeing a huge amount of innovation at the moment I think we can have a pretty good idea of at least some of the ways in which it will all settle down. History is full of examples of innovation and shows that over time there's generally a pattern.

The web, mobile and other areas are so young that it's anyones guess what the long term revenue models will be. In truth though I don't think it's hard to guess. Newspapers, magazines, tv, radio have, for decades survived very well on advertising for the simple reason that it removes the biggest barrier to getting customers, asking for money. By just delivering content free or hugely subsidised as in newspapers and magazines you can deliver at scale.

I just read about Googles success on their mobile operating system named Android. I like the article. It's the first I've seen that makes clear the similarities yet clear differences between Apples and Googles approach to monetising the mobile market.

My simple view is that charging upfront generally limits your market size because it presents an important hurdle to getting into the product or service. Hence I can't see Apple selling as many devices long term as those running Google. Apple will do very well and get maybe 10% of the market (who can really predict the amount) but Google can and most definitely will get atleast 50% (Don't forget there are other big players like HP and RIM who want a piece of the pie too)

The reason., because Googles Android is free to the user, Apples is not. Apple charges a premium for the quality and reliability of its products, but its core strength is its biggest weakness in terms of scale. Apple just can't deliver features at the rate and cost that Google can because Apples features must be perfect before release, but Googles don't have to be. Googlers are more like explorers who expect freedom to do as they wish with their device. Apples fans want things to 'just work' and will accept limitations in design to get this. All this control and attention to detail costs money and takes time.

So, in my view, it's never been a war. It's just two different approaches to delivering mobile markets. Both are delivering amazing results to their fans but their philosophy will ultimately determine who leads in each mesasure. Apple will always have quality and security at cost. Google will eventually get scale and flexibility and value for money.

The Microsoft and Apple story was similar for similar reasons. Microsofts goal was scale, Apples, quality. It's not the only time this has played out. It just seems that way.

History has countless stories of similar rivalries. England has such a long history of new money vs old money. The new way of doing things vs the old way.  In the UK Power used to be held by just a few lords and one monarch and then a few people below them. Over time there have been countless struggles with new ideas outcompeting the old ideas. It's just evolution. Those who survive adapt. Old powerful families either found a place in the new order by, either fading into the background whilst holding onto their powerful links. Keeping power and wealth by helping those in power. They just get less attention, or they adopt the new ways and find a way to make a living.

The English monarchy are a good example since they're very much a German family by heritage. However, like many families at the turn of last century, they changed their name to Windsor and adjusted to the new order that was coming. They avoided the dissolution of the monarchy by giving back much more power and started showing what the monarchy could do for the country instead of the people having to do everything for their monarchy. This was just part of a long political struggle going on throughout the UK and the world in general.

While it may seem a stretch to compare the changing attitudes to the monarchy with a struggle between two heavy weight computer companies I feel it is just because it's still all about people and their dreams. Not everyone has money and power but everyone has dreams. My dream is all about freedom and that includes freedom from software and hardware.

I see Apples approach as dictatorial, the opposite of free. I envy what so many iphone users can achieve but I won't put money and effort into a product that's designed to tie me down. Mainly because I don't feel Apple can fulfil my dreams in the long term. I feel I will never be free because every advance comes at a financial cost. One that I may not be able to bear in time.

I also cannot think of a dictatorial country that has managed to compete equally with one where democracy rules. The main reason is that democracy encourages competition and free thought. Free thought in a competitive environment encourages innovation and constant improvement, constant evolution of process.

Google on the other hand is obviously more of a democracy. What I lose in clear decisions and straightforward approaches, I gain in freedom to achieve anything I put my mind to. I know that there will always be an android device within my price bracket and that Google will always care about me as an individual. Regardless of my situation they will want to support me. Their business model is designed that way. Democracy has led to openness. Each generation seems to be more open than the last. Mainly because we all seem to benefit from removing barriers and because new tech and ideology removes barriers.

I also feel that Apple essentially does all the development itself. Sure there are tons of apps that they didn't write but I'm talking more about the core of their products. Googles fundamental belief is about bringing people into their products in any way they can. Many of the 3rd party improvements to the Android operating system have been incorporated into the core release, apps2sd is a recent addition to name but one. Further to that I've found it easy to comment on and suggest new features to every Google product I've wanted support on.  I don't know of this happening with Apple. They're certainly not quick to explain the meat behind any  issue that arises in their products.

Ok, I feel like I'm starting to go on a tirade. The main point I wanted to make is that they're both winning. They've just got different goals. These are not new goals. Individuals, companies and even countries have  had these goals before and history is littered with how these worked out. Each company will win different types of customers because their followers will have different dreams. the dreams you have often determine the sacrifices you're prepared to make. So those behind Google and Apple are likely to have different ideas about the sacrifices they'll make to achieve that dream. I just think that, long term, Googles dream is cheaper and brings freedom. Apples makes you addicted to perfection which is an impossible dream so you'll never be free. And I think the worlds history on democracy over dictatorships bears out the idea that democracy will win long term. That's my hope anyway.

So this kind of competition is common. It happens every so often in most markets and the outcomes do have patterns. I haven't done an in depth analysis. Just thought I'd put my ideas down so I can see if they pan out or not. See if I'm talking nonsense :-).
Enhanced by Zemanta