Friday, September 14, 2012

Applikationsregissören

“Ja, vi spelar in en film!”

In English
Applikationsregissör Arne Evertsson bakom Javakompilatorn (?)

En filmproducent har det övergripande ansvaret för att en film blir till. Det handlar om att se till att det finns ett manus, finansiering, och hitta rätt personer att utföra dom olika kreativa och praktiska uppgifterna i ett filmprojekt. Inte minst skall producenten stöda regissören som har det konstnärliga ansvaret för filmen.

Konstnärliga anvaret? Det låter som måleri eller skulptur. Regissören hackar fram en skulptur som skall väcka känslor, tankar och förhoppningsvis förmedla ett budskap. Materialet och verktygen utgörs av manus, skådisar och alla möjliga superproffs inom sina konstnärliga hantverksområden.

Mitt intryck är att regissören både pekar och leder men sedan också håller sig undan så att var och en kan bidra med sitt kunnande. Producenten finns alltid där som en axel att gråta emot (?).

Men vad har allt detta med applikationsutveckling att göra? Låt oss titta på samtidens defacto-standard vad gäller mjukvaruutveckling, projektmetodiken Scrum.


Scrum?

Utvecklarna, scrummästaren och produktägaren har huvudrollerna i ett Scrumprojekt. Låt oss titta närmare på produktägaren. Produktägarens huvuduppgift är att kontinuerligt föda teamet med en prioriterad lista av uppgifter. Utvecklarna betar av listan från toppen. Produktägaren stuvar om, lägger till eller tar bort från listan allt efter behov. Varje punkt i listan är beskriven i termer av affärsnytta, inte teknik eller tillvägagångssätt.

Detta är en mycket sund inställning till programutveckling, och arbetssättet är grunden för alla agila metoder, inte bara Scrum. Det finns dock ett antal frågor som inte besvaras av Scrum alls, viktiga frågor där utvecklingsteam ofta famlar i blindo.

Innan en uppgift kan påbörjas måste den vara tillräckligt väldefinierad så att teamet kan ta sig an den: Storyn skall vara backlog-ready. Det vill säga, uppgiften skall vara mogen att hamna på att-göra-listan. Vad betyder det? Oklart. Denna fråga är också relaterad till en annan: När sker interaktionsdesignen? Är användargränssnittets utformning en förutsättning för att påbörja utvecklingen eller sker detta samtidigt eller till och med senare? Också oklart.

I jobbannonser för mjukvaruprojekt används ofta rollbeskrivningar som business analyst, kravfångare, och verksamhetsanalytiker. Man skall hålla workshops, skriva kravspecifikationer och vara bryggan mellan verksamhet och teknik. Men det är ändå beställaren och styrgruppen som beslutar om projektets mål och innehåll. What? Jag tappade tråden där. Vart tog produktägaren vägen? Finns någon projektledare inblandad här? Är kravprioritering detsamma som applikationsdesign? The plot thickens...


George och Steven har svaret på gåtan

George och Steven. Eller kanske tvärtom?
Dom goaste vännerna George Lucas och Steven Spielberg ligger bakom dom klassiska filmerna om Indiana Jones. George är producenten. Steven är regissören. Tänk om det är så att George och Steven har fattat det där med att arbeta i projektform?

Låt oss gifta ihop produktägaren från Scrum med regissören från filmproduktion. Låt oss kalla bebisen för Applikationsregissör. Det första applikationsregissören gör är att sätta likamedtecken mellan affärsnytta och användarnytta. Om ingen tittar på filmen kommer filmbolaget inte att tjäna några pengar. Om inte användaren har nytta av applikationen kommer företaget inte att tjäna några pengar. Så enkelt är det faktiskt: Affärsnytta = Användarnytta. Detta är ett faktum som ofta försvinner bland powerpointpresentationer och projektdokument.

Regissören har visionen. Regissören har förmågan att konkretisera visionen i projektmålet. Visionen kommer från en djup kunskap om behovet, men i ännu högre grad från den kreativa förmågan att se lösningen framför sig. Applikationsregissören är behovsfångaren. Applikationsregissören designar applikationen och blir därmed kravställaren. Han är CID, Chief Interaction Designer. Applikationsregissören realiserar användarnyttan.

Men vänta lite nu. Spola tillbaka. Det måste ju till en verksamhetsexpert för att kunna se verksamhetens behov. Där har du din applikationsregissör. Eller hur? Ja. Men bara om nämnde verksamhetsexpert också är expert på applikationsdesign. Om inte, kan verksamhetsexperten vara ett stöd för applikationsregissören, ett fantastiskt bra stöd. Inhämtandet av verksamhetskunskap är en nödvändig och synnerligen intressant uppgift för regissören.

För att återknyta till bröderna Skägg, hur gör dom nu det här?

George och Steven har långt innan inspelningen jobbat på ett manus tillsammans med manusförfattaren. Det finns en väldigt tydlig bild av vad som skall åstadkommas. Oberoende om Steven skrivit manuset på egen hand eller ej så blir manuset hans egendom i den kreativa processen. Innan inspelningen startar sätter man upp varje scen på väggen i form av storyboards. Bara för att inspelningen har kommit igång är inte manuset gjutet i sten, utan ändringar och tillägg görs löpande under produktionen.

Läs nu om ovanstående stycke, men byt ut inspelningen mot implementationen, manuset mot applikationsdesignen, manusförfattaren mot interaktionsdesignern, scen mot story, storyboards mot wireframes.

Okej, låt oss lämna George och Steven för en stund.


Så här tror jag man skall göra

Innan teamet med programmerare sätter igång finns en design. Den är inte komplett, innehåller inte alla detaljer, men den ger en utmärkt bild av vad vi föreställer oss är slutmålet just nu. Detaljer finns däremot för dom stories som är högst på priolistan. Regissören jobbar alltså med ett interaktionsteam som innehåller interaktionsdesigner och grafisk formgivare, och dom ligger ständigt före utvecklingsteamet. Innan en story/uppgift är färdig för priolistan låter regissören också en eller flera utvecklare göra en teknisk design och uppskatting av omfattningen. På detta sätt föds priolistan med konkreta genomförbara uppgifter. Allt eftersom stories blir färdigprogrammerade åker dom tillbaka till interaktionsteamet som evaluerar användbarheten och tar med sig slutsatserna i det fortsatta arbetet.

Som tur är slipper vi den Hollywoodska massiva monstermaskinen som en filminspelning är. Vi systemutvecklare kan vara mycket mer lättrörliga. Den chansen försitter vi inte utan det agila tankesättet är grunden för hur vi jobbar.

Jag har inte sagt så mycket om Applikationsproducenten men denna roll liknar nog mer det som kallas Projektledare. Kanske stoppar man in en del av vad Scrummästaren gör i producentens arbetsuppgifter också. Tillsammans med applikationsregissören har han ansvar för att användarna får glädje och nytta av systemet.


Slutsatser

Det är fyra saker jag vill säga:
  1. Fokusera på användarnytta och du kommer att skapa affärsnytta.
  2. Interaktionsdesign är applikationsregissörens främsta verktyg.
  3. Applikationsregissören är expert på att designa applikationer. Domänkunskap och verksamhetskunskap är input till designprocessen.
  4. Jobba med två team, interaktionsteamet och utvecklingsteamet. I-teamet ligger ständigt före, men även efter, u-teamet.
Applikationsregissören är alltså en produktägare a la Scrum fast med ett tydligare mandat och arbetsuppgifter. Han har en djup förståelse för användbarhet och användarnytta. I hans huvud förvandlas behov till en konkret design och han leder teamet hela vägen in i mål.

Thursday, May 24, 2012

Could manual testing work?

Let me tell you about my experience with software testing. In many projects (but not all) there has been a group of testers. Their job has been to test the system after the developers are done, file bug reports, wait for fixes, and then re-test. It all looks sound on the surface, right? However in practice this classical setup has a number of  problems :
  1. The tester isn't part of the team. He needs written documentation to know what to test. Somebody has to write this very detailed documentation.
  2. Testers I've worked with have had absolutely no clue on how to automate even the simplest test cases. Instead they have spent lots of time doing monkey work.
  3. The fact that there is a specific phase for testing means the developer, consciously or unconsciously, gets lazy with his own testing. That results in many bugs.
  4. If there are many bugs most of the tests will probably be impossible to run. The tester will have to wait for the developers to fix the bugs.
  5. Developers will quickly hack the bug fixes since we're already out of time.
  6. Nobody will know when or if it will be possible to deliver anything to the actual users.
 The  solutions  are pretty obvious. In the same order as above:
  1. Put the tester into the developer team. The tester will now have a chance to write tests even before code gets written.
  2. The tester is a programmer capable of automating tests.
  3. There is no testing phase. Stories are done only when they have been tested.
  4. No waiting for fixes will occur.
  5. No quick hacking will occur.
  6. Delivery is on demo day.
Problem solved. Relief.

 Right? 

Actually... Yes, I think so!

In my current project (which more or less follows Scrum) however we have yet to set up automated testing at a story level. The test cases so far have been completely manual. This fact gave rise to a discussion today among team members that I summarize like this:

"The thing I'm working on now affects more than just one story. I'll probably need to re-test quite a few stories and forms. What if the next story is similar? I'd have to re-re-test those same things again! That's going too take to much time. What we need to do is to have a code-freeze a number of days before sprint ending. We'll use those days to test the whole system and fix whatever bugs turn up."

Yes, that would do it.

 No! Panic Button! Incoming Godzilla! Iceberg on starboard! The drachma has arisen from the dead!

If we do this, we re-introduce a testing phase at the end of the sprint. Having a testing phase leads to sloppy developers, which leads to many bugs, which leads to end-of-sprint chaos!

The only really good solution is to automate the testing. But since we haven't done that we need a compromise solution. Suggestion for manual testing:
  • Multiple story implementations that affect the same existing functionality get tested together and just once. Before code-freeze. Fix for: Time
  • There is a code-freeze and the extra days will help us confirm the done-ness of stories. The testing will cover functionality we didn't even think about when doing story specific testing. Fix for: Regression testing
  • Only stories that are completed according to the DoD before the code-freeze occurs, may be included in the sprint delivery. No stories are allowed to enter into the state of Done after code-freeze. Fix for: Bad habits
That might work. Let's see if I get a chance to try it out.

Wednesday, April 18, 2012

Browser versions and testing Swedish web sites

Judging from the Top 12 Browser Versions and the Top 5 Operating Systems in Sweden in April 2012, the following is my list of OS/Browser/Versions necessary to test on. I've exluded iOS since Sprend doesn't work on it. I might add Linux even if it doesn't reach very high on the OS top list.

And btw, who said the browser was done? Hopefully the list will be even shorter as all browsers move towards continuous upgrading.




Wednesday, April 11, 2012

The Gate Challenge

Cinemas get more competition every year. Films are being watched in home cinemas and on smartphones.  If the cinema business is going to keep up it needs to do two things:
  1. Enhance the experience 
  2. Reduce the friction
Since Peter Jackson is busy with the first, let's concentrate on the latter: reducing the friction when buying a ticket. Picture this: You're walking down the street with a friend and you see the cinema building 50 meters ahead. Your friend asks: Fancy catching a flick? And by the time you reach the doors you are holding two tickets in your hand. Magic?

Let's back up. Fifty meters take roughly 30 seconds to walk. In that time you need to grab your phone, start the ticket app, select a movie, pick seats, and pay for the tickets which are delivered within the app itself.

Would it even be possible to create this app? I think so. As it turns out it takes 30 seconds to walk from the gate of Råsunda Filmstad to the doors of the three screen "multiplex" Filmstaden Råsunda. This is..

The Gate Challenge: To create and app that lets you pick up your phone at the gate of Råsunda Filmstad and have the tickets in your hand before you reach the doors of the cinema.

Let's say that in pictures.



1. At the gate of Filmstaden: 30 seconds left


Details

  • The app has just been started and is showing tonights movies.
  • The cinema is automatically selected based on either proximity or last purchase. I guess last purchase makes more sense. The user may choose another cinema if needed.
  • The movies are showing in chronological order, and the list contains only those movies for which tickets can be bought.

2. Passing Portvaktsstugan: 23 seconds left


Details

  • Hunger Games at 17:30 has been selected
  • The movie has an IMDb score of 7.7 of 10, or 4 stars. The user may select the rating system of his/her choice, or a combination of different rating systems.
  • The user selects the number of tickets with the buttons at the bottom.

3. Outside SDI Media: 15 seconds left



Details

  • It's possible to zoom, pan and select seats just using your thumb.
  • No double tapping or multifinger gestures are needed.
  • There is no count down before it's too late to select.
  • The available seats are updated in realtime.

4. At the Little Studio: 7 seconds left


Details

  • The last step is to confirm the purchase.
  • There needs to be a countdown timer here after which the seats are released. But we can wait to display the timer until 30 seconds or so has passed.
  • But hey, what about the 30% cut that Apple takes for in-app purchases? Not a problem since the app doesn't utilize the in-app purchase function of AppStore. Apple won't mind since the product sold will not be consumed within the phone. We are free to offer credit card payments or any other payment solution.

5. Just outside the cinema entrance doors: Time is up!


Details

  • Yes, we made it in 30 seconds! The two tickets are now showing in the app itself.
  • There is no back button and you can't buy more tickets before these ones have been used.
  • The tickets inform you that the scheduled starting time is Now!

6. Cinema lobby


Details

  • The ticket taker swipes his finger in an S shape to "tear" the ticket. Or some other shape.
  • One might want to switch shape regularly to make counterfeiting difficult.


7. Just relax


Details

  • Relax and don't forget to switch on Movie Mode (= Airplane Mode).

Finally...

Råsunda Filmstad also houses the headquarters of SF Bio. The question is, is SF up for the challenge? I'm right here should you need a helping hand.




Wednesday, March 21, 2012

Titanium Breaks

I should probably re-deploy and it'll work...
I've just finished implementing the ROT-avdraget app for iOS as well as for Android. The iOS app was made with Xcode, and the Android app was made with its native tools plus the excellent IntelliJ IDEA.

For the last few days I have tried to re-implement the app using Appcelerator Titanium. The question was whether I could save any time using a cross-platform tool instead of developing in the native environments. The result has been very disappointing. It's difficult even to get the provided sample apps to run, particularly on the Android emulator. Also you can't debug on hardware, so you have to rely on the buggy emulator support.

If only Titanium worked it could be a really nice environment. Most of the development time with the ROT-avdraget app was spent creating the user interface. I found both the iOS interface builder and the Android xml layouts to have a lot of room for improvement. With Titanium the gui is created in code and I think that is a good thing. I found it easier to put views in their right place with Titanium JavaScript code than with the native approaches.

If Titanium is ever going to be good it has to abstract away the differences between the native platforms (when that makes sense). Let me show you a specific example how that fails.

At the top of the screen there is a webview that shows a banner. Before the banner loads, an imageview displays a default image on top of the webview. As soon as the page load has completed, the default image fades away. If the page load fails we wait for 60 seconds and try again.

For iOS the code is very straightforward.
  • In webView:didFailLoadWithError we wait 60 seconds and then try again.
  • In webViewDidFinishLoad: the default imageview is faded out.
This is the code:

- (void)webView:(UIWebView *)webView
        didFailLoadWithError:(NSError *)error
{
    [self performSelector:@selector(openUrlInTopBanner)
          withObject:nil
          afterDelay:60];
}

- (void)webViewDidFinishLoad:(UIWebView *)webView {
    [self fadeOutImageToShowBeforeBannerLoads];
}

For Android the logic is slightly different.
  • onReceivedError() sets a failure flag, and then creates a timer for reload.
  • onPageFinished() will get called on both success and failure which is why we need to check the flag before fading out the default imageview.
This is the code:

public void onReceivedError(WebView view, int errorCode, String description, String failingUrl)
{
    isFailedTopBannerPageLoad = true;
    if (topBannerLoadTimer == null) topBannerLoadTimer = new Timer("topBannerLoadTimer");
    topBannerLoadTimer.schedule(new TimerTask()
    {
        public void run()
        {
            isFailedTopBannerPageLoad = false;
            openUrlInTopBanner();
        }
    }, 60 * 1000);
}

public void onPageFinished(WebView view, String url)
{
    if (!isFailedTopBannerPageLoad)
    {
        fadeOutImageToShowBeforeBannerLoads();
    }
}

And here's the Titanium version of the same bit of functionality. The code is a reflection of the iOS code above:
 
topBanner.addEventListener("error", function(e) {
    setTimeout(function() {
        openUrlInTopBanner()
    }, 60 * 1000);
});

topBanner.addEventListener("load", function(e) {
    fadeOutImageToShowBeforeBannerLoads();
});

It looks simple enough. When run on an iPhone it works exactly like the Objective-C code. But bad things happen as you run it on Android:
  • The load event listener gets called when the page succeeds. Good!
  • The load event listener gets called also when the page fails to load. What? Hmm, so it works like the native Android event listener?
  • The error event listener never gets called.
  • Titanium Fail!
So I would assume there are workarounds. The problem is that there had better exist a truck load of workarounds. I kept a little log during the development. Here is part of that log:
  • The New Project Wizard fails to find the Android sdk! Not until I create an empty folder for an old version of the sdk does it succeed to locate the sdk.
  • The Hello World sample project fails to deploy to the iPhone simulator. On the second attempt... it mysteriously works.
  • The Hello World sample projects fails to deploy to the Android simulator. The second attempt also fails. After restarting Eclipse... it mysteriously works.
  • Deploy to an iOS device uses iTunes synchronization. Since I don't normally sync my iPhone with iTunes on my developer machine it means all the installed apps are deleted when I deploy the Titanium-built app.
  • The call to Ti.UI.createImageView() gives a runtime error. Workaround: Rebuild and redeploy and it works.
  • createImageView(): Android requires a slash at the beginning of a path. iPhone does not.

The Android simulator (or is it emulator?) is a story of itself.
  • Starting the simulator creates five console logs. Where does one look for error messages?
  • I need to disconnect the physical Android device to run the app on the simulator, or else I get "More than one device and emulator".
  • Android simulator hangs when deploying an app. And again. And again.
  • Rebooting computer. Trying again. Android simulator hangs on "get app.js"...
  • Finally the app installs and starts. I press the back button. Next deploy fails. I uninstall the app from within Android. Now it seems to work again, for a while.
I'm giving up on Titanium. It is just broken.

It seems I'm not alone:




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.





Archive