Arne Evertsson

I'm completely operational and all my circuits are functioning perfectly.

Tuesday, February 28, 2012

Android GUI building

This post is an update to my previous post about xml vs programmatic GUI development.


After a bit more Android experience it seems to be true that the xml syntax is indeed simpler than the Java equivalent. The Java code turns out to be even more verbose than the xml is. Here is a simple example:


ScrollView rootView = new ScrollView(this);
setContentView(rootView,
  ScrollView.LayoutParams.FILL_PARENT,
  ScrollView.LayoutParams.FILL_PARENT));
LinearLayout linear = new LinearLayout(this);
rootView.addView(linear,
  new LinearLayout.LayoutParams(
    LinearLayout.LayoutParams.FILL_PARENT,
    LinearLayout.LayoutParams.FILL_PARENT);
Also, it is more difficult to find documentation for the programmatic method. You are expected to create the GUI with xml.


It is still true that debugging xml is impossible. However, it hasn't been necessary to debug this xml. The declarative programming style seems to work in this case.


All the above speaks for the xml approach. However, the xml is simpler not because of some inherent quality, but rather because the Java API is really bad.


For my next Android project I might try to wrap the view classes into user-friendlier versions. After all I can make my own API if I'm not happy with the one provided by Google. Perhaps like this:


MyScrollView rootView = new MyScrollView(this, LP.FILL_PARENTLP.FILL_PARENT);
setContentView(rootView);
MyLinearLayout linear = rootView.addLinearLayout(LP.FILL_PARENTLP.FILL_PARENT);
A third approach would be a visual GUI builder. The one in Xcode 4 is a good start, but far from really good.

Sunday, February 12, 2012

Debugging XML?

Let me quote the Hello World tutorial at developer.android.com:

"The general structure of an Android XML layout file is simple: it's a tree of XML elements. ... This structure makes it easy to quickly build up UIs, using a more simple structure and syntax than you would use in a programmatic layout."

Hmm, let's try that. First the xml version:

<TextView
  android:id="@+id/textview"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:text="Hello, Android"/>
And now the Java version:

TextView tv = new TextView(this);
tv.setText("Hello, Android");
Is the xml version simpler? Not sure. It's a little bit verbose but still readable.

What about editor support? In a good editor, like that of IntelliJ, I can Ctrl+Space Java code as well as Android layout xml. So, no difference.

But there is one difference:

You can step Java code, but you cannot step XML!

Case closed.





Wednesday, January 25, 2012

Safari Books Online

I signed up for Safari Books Online today because I wanted to refresh my iOS skills with the latest edition of Beginning iOS 5 Development: Exploring the iOS SDK. The experience is however far from what I expected. Safari Books Online has been around for years and years so I thought they had figured it out and ironed out the rough edges with online reading.

The big screen reader is Flash based and it has a number of problems:
  • The text is blurry.
  • The pages are formatted for print, not for screen reading.
  • The scrolling speed is so fast it's almost not usable (at least on a MacBook trackpad).
The "mobile optimized site" is perhaps not so optimized:
  • The pages are shown as blurry images.
  • The text is so small it is barely legible.
  • There is no pinch-resizing.
  • The zoom function makes the pages just too large to fit in landscape mode on an iPhone 4.
  • The system doesn't remember where you left off, when you switch between the big screen reader and the mobile site.
And there's more:
  • Why aren't errors in the text fixed?
  • Why are links in the text not clickable?
Who said things are moving fast in our business? The IT sector is moving sloooowly.

But guess what, I'll probably become a paying customer just because of the convenience of immediate and ubiquitous access.

Wednesday, November 16, 2011

Go native. Web apps aren't there yet.

What's so great with a native app, when you can build a web app that works across all mobile devices? If you're just aiming to provide information and have no use of all the fancy hardware of smartphones, what's the point with learning Objective-C etc?

Seems pointless and expensive to write that app.

Hey, I want an app! Everybody's got an app, I want one too. They are.. you know.. apps.

That's no good. Here is list of real reasons for writing that native app: 
  1. Apple is running an apartheid system against web apps. Se below.
  2. A web app can't cache data as easily as a native app, which leads to slow responsiveness (or is this true with html5?)
  3. It is close to impossible to make a web app respond to taps as fast as a native app.
  4. It's really difficult to make a web app as stable as native app. I've compared the Facebook native app and web app: The web app just simply does not do anything when I tap "Check In".
Apple's apartheid against web apps:
  • A web app has to share browser windows, and there are just 8 of them, before one app gets kicked out.
  • A web app will reload even if it's already loaded => slowness.
There you go. Make that app.

Wednesday, September 14, 2011

Writing our own stories


"I write my own stories. Honestly, I do"



I attended the Java 7 meet-up the other day where Oracle spoke about the Java 7 release as well as about the development of Java taking place here in Stockholm. I didn't know the Stockholm offices of Oracle had so much to say about the future of Java, but obviously they do.

They also promised to answer all our questions as long as we didn't ask anything about any ongoing lawsuits. Right, Oracle hates Google, or as they put in the talk: "We have a bad story" with smart phones. A bad story. It seems they are writing that bad story themselves. I just can't see how I as a developer can benefit from company A suing company B about patents. None of that makes sense to me. Lawsuits are symptoms of large corporation disease ("corporitis"?). The questions is: What can big Oracle do that a small startup in Gamla Stan cannot?


So what's new in good old Java. Nothing much it seems, apart from a candy bag of syntactic sugar: Project Coin. Syntax is our user interface into the programming language and I find syntax enhancements very important. But it's of course hard to change the syntax of an existing language.

There is a solution that requires no committee meetings or consensuses. The IDE makers can innovate freely and provide new views of your code (without changing the actual source). I think the time has come to go beyond font size and line length in code editor view settings. There is even the opportunity to scratch our own itch and make an IDE plugin with the sugar we crave. IDE:s have come along quite a bit since I started programming and the next chapter is even more promising.

Wednesday, August 31, 2011

Victoria Tower

The new skyscraper in Kista, the Victoria Tower, is not as bland as I first thought. Modern architecture can be just incredibly boring. Everything is straight and grey.
But this building seems to change both color and shape with the weather. Or is it just a grey tall box like most other new buildings? Not sure yet.

Monday, August 29, 2011

Att skriva filmmanus




Jag var på Filmstadens Dag igår vilket är en trevlig liten fest. Man frågar sig om man är i fel bransch (inte första gången). Kanske kan jag kombinera IT-branschen med filmbranschen via ett uppdrag på SF?

Jag kunde inte låta bli att köpa boken "Att skriva filmmanus" av Fredrik Lindqvist. Om det är någon konst som är inhöljd i en Avalons dimma av mystik och magi så är det hur man skriver ett bra manus, till en film, en bok, en serie eller ett spel. Manuset är nyckeln till kvalitet. Men hur tusan gör man? Jag har aldrig brytt mig om att ta reda på det, även fast jag slitit mitt hår i skolans uppsatsskrivningar och under mina sommarlovs serietecknande.

Jag har en känsla av att berättarteknik kan tillämpas på många olika områden, även om man håller ett tekniskt föredrag eller kanske till och med för skrivandet av blogginlägg?

Kan man berätta en story i ett GUI för en nytto-app? Det tål att spåna över. I vilket fall kan manus vara en viktig komponent i läroappar, speciellt om man gör dom som spel. Det skall bli en intressant läsning (när jag nu skall hinna läsa, vilket är en annan fråga).

Arkiv