Free Software Movement

Det finns en hel del missförstånd kring fri programvara. Ett klargörande kopierat från FSF:

In general we do not believe it is wrong to develop a program and not release it. There are occasions when a program is so useful that withholding it from release is treating humanity badly. However, most programs are not that important, so not releasing them is not particularly harmful. Thus, there is no conflict between the development of private or custom software and the principles of the free software movement.

Återkoppling från en Coding Dojo

Det är otroligt kul och inspirerande att se Coding Dojos tas emot så väl ute bland de företag jag besöker. Att det är väl mottaget bland utvecklare är uppenbart och kan bl a förklaras med “Code wins arguments”. I “gamla” inkörda team där diskussioner gått i stå och nötts länge kan helt plötsligt helt ny dynamik uppstå. De “gamla” argumenten som gått fram och tillbaka men bara varit abstrakta och teoretiska skall helt plötsligt omsättas i kod, med/inför kollegorna och “helt plötsligt” går det från abstrakt till konkret och inte bara fåtalet engagerar sig och har en uppfattning, utan flertalet.

De Coding Dojos jag driver hos kunder är just detta – praktiska övningar med ett mål eller en poäng. Ingen föreläsningsserie man sitter och nickar igenom och sedan släpper vind för våg. Med riktiga övningar, där alla deltar och skriver kod själva ökar deltagandet, engagemanget och det kritiska granskandet.

Eftersom det ofta uppstår diskussioner med uttryck som “jag brukar göra såhär”, “oj, så har jag aldrig gjort, eller tänkt” så är det viktigt att det inte finns lönesättande chef(er) på plats. Om deltagarna är rädda för att säga fel och börjar väga sin ord så försvinner en stor poäng med dojon. Jag försöker få alla att vara spontana med hur de tänker, att exponera hur de jobbar utanför dojon så att de kan få konstruktiv feedback på sitt arbetssätt. Lönesättande chef och/eller beställer behöver givetvis återkoppling också. Här följer ett exempel från förra veckan.

Hej Kund!

Efter lite hackiga, trevande steg med första övningen tyckte jag mig se en enorm skillnad till tillfälle två. Det märks att flera utvecklare försökt sig på det vi övade i vardagen! Jag tror mig se att så gott som alla utvecklare har fått en ny infallsvinkel till hur de ser på sin kodskrivning och den synen utvecklade vi med en mer realistisk övning ihop med mockning. Det var mycket bra frågor som dök upp, vilket tyder på att de är engagerade, intresserade, verkligen försöker anamma en annan kodordning och har en sund kritisk inställning till vad de gör själva (det är ju inte jag som skriver koden under övningen – jag bara guidar och ger tips)!

Övning 1:

Vi tog en enkel basövning (String calculator).
Vi introducerade red-green-refactor, Arrange/Act/Assert, bottom-up.
Vi tog baby steps bokstavligen med 1 minut som tidkrav att gå från röd till grön.
Vi såg triangulering som ett sätt att driva fram funktionalitet.
Grå zon: “täcker testen all funktionalitet? om inte, har vi använt test-driven utveckling?”

Övning 2:

Vi tog in en ny, ganska stor uppgift som är mycket mer realistisk (tagen från produktionskod).
Vi lade på ett nytt moment/tanke i form av en “testbacklog”. (Verkade vara en ny idé – diskuterade VAB-scenariot och vikten av att kunna dela kod ofta.)
Vi lade på mockning med Mockito. (En del var redan bekanta med Mockito.)
Grå zon: “ett par antydningar till att ändra kod utan att testen uttrycker den funktionella ändringen i koden”.
Vi refaktorerade kod lite oortodoxt (utan test, utan undo/bortkommentering).

Det var mycket motiverande för min del att se utvecklingen i teamet, det var en helt annan “mognad” i TDD-tänket och ett bra driv/bra dialoger. Parprogrammeringen såg bitvis fullständigt klanderfri ut – mycket kul att se! Nästan all kod drevs fram från test (två, tre tillfällen fanns antydan till att skriva kod som inte var testdriven/täckt av test).

Utvärderingen i slutet bjöd mer på kod- och designdiskussioner (jag vill aldrig avbryta sådant) så vi hann inte “utvärdera” så mycket, men på tavlan skrev jag upp:

+ bra frågor
+ bra övning
! refactoring gjorde koden mycket mer läsbar
! smidigt med @Mock
? Använda TestNG nästa gång

Mitt förslag är att vi nästa gång utvecklar i flera par parallellt (en dator per par med Eclipse är vad som behövs), lägger på Clean Code-aspekter och använder samma uppgift och ser hur vi kan få koden att se ut på olika sätt.

Munin template update

I like to have day, week and month in one view.

/etc/munin/templates/munin-nodeview.tmpl
<tr>
  <td><a href="<TMPL_VAR NAME="URLX">"><img <TMPL_IF NAME="STATE_WARNING">class="warn"</TMPL_IF><TMPL_IF NAME="STATE_CRITICAL">class="crit"</TMPL
  <td><a href="<TMPL_VAR NAME="URLX">"><img <TMPL_IF NAME="STATE_WARNING">class="warn"</TMPL_IF> <TMPL_IF NAME="STATE_CRITICAL">class="crit"</TMP
+ <td><a href="<TMPL_VAR NAME="URLX">"><img <TMPL_IF NAME="STATE_WARNING">class="warn"</TMPL_IF> <TMPL_IF NAME="STATE_CRITICAL">class="crit"</TMP
</tr>
</TMPL_LOOP><!-- End of SERVICES loop -->
</table>

Four Week Review of Lenovo ThinkPad Tablet

Lenovo ThinkPad Tablet Product Image

I recently got myself a Lenovo ThinkPad Tablet. As with most gadgets, there’s a hate/love relationship and this post is my list of pros and cons. But first – the background to why I got this device is that I wanted to

a) be able to more efficiently read RSS streams, and

b) be able to read, write and reply to e-mail.

My previous phone, a Nokia N900 fully help me achieve the e-mail tasks. It was really great in all ways related to communication (Skype, Jabber/GTalk etc). However, the browsing and blog/RSS reading experience was not really up to the level I found acceptable. It basically was too slow: I lost interest and jumping from RSS to a browser was way too slow.

This summer I got my first Android based phone, a Sony Ericsson Xperia Arc. It works good in almost every way. (The address book is terribly slow – I have just under 800 contacts and somehow that is a problem performance wise. The N900 handled this much better, and a physical keyboard also speeds up filtering and helps UX aspect.) However, reading RSS and web pages on this device I found to be too slow, again. So, while I got a device with a much greater list of available apps (which I rarely have any use for), a much worse calendar and sub-par ability to write and reply quickly to e-mail –  it essentially didn’t meet my expectations. The N900 fixed task b, the Arc fails on both tasks a and b.

I will not compare this ThinkPad Tablet  with an Ipad – I knew upfront that the user experience would be flawed in comparison. I’ve been using both versions 1 and 2 of the Ipad, and they simply don’t cut it. Although the major issues with version 1 (multitasking and switching between apps) has been fixed, as soon as I want to contribute/create content the Ipad runs up short. The on screen keyboard is OK if you want to type less than 140 characters, but I typically actually type when I work (I’m productive – I produce code and add value to conversations, as opposed to merely consume).

So, this is a four weeks review of the latest geadget of mine.

Lenovo ThinkPad Tablet Product Image

Pros

Meets both functional expectations, a and b (YAY!)

It works great for reading RSS (GReader Pro works almost flawlessly – only bug/feature enhancement would be to mark a an entry as read when moving away from it, not just by having opened it) and switching to a browser is acceptably slow (the switch is instant, loading the page is primarly limited to the 3G connection – the Dolphin for Pad app does a great work).

Contact manager

Works really well and makes great use of this screen. No lag at all, speedy and help me get work done. (However, I expected to be able to make phone calls, not sure why this is not enabled.)

Calendar

Works really great on this screen

Decent

Battery is perfectly OK

I’ve only been using it for a couple of weeks by now, but it lasts a full day playing Spotify music (from local storage mostly) for 3-4 hours. Pulls/receives (push) ~50 e-mail. Pulls RSS feeds every 4th hour. It still has more than enough juice to feed my RSS reading and e-mail replying urge on the tram on my way home.

Hardware design

Hardware button to turn auto orientation on and off. It’s light enough to carry around. Keyboard is wonderful to type on. I don’t use the pointing device and would actually prefer to have it removed or at least disabled (note about Ctrl key below).

Format, Screen, Performance

Well, in most regards this is really a great tool – I enjoy using it more than I’m annoyed by the issues it brings (see below). It’s almost like the thin computer with detachable keyboard I guess I’m really after.

Cons

DOES NOT CHARGE BATTERY WITH NON-BRANDED CHARGER

This is insane. I feel the industry left that problem years ago. Here it comes back as an uninvited ghost. This is really ridiculous. I already have a small array of micro-USB chargers at my desk and at home. WHY OH WHY do I have to buy TWO chargers for this tablet (on for home, on backup at work – and ideally yet another one for travelling/on the move). Seriously, this is ridiculous. (However, since the battery is OK, this becomes less of an issue than one can expect. As the battery’s performance degrades, I guess this’ll become more alarming.)

Screen lock is not responsive enough

It actually is something I struggle with more than half of the times I unlock the screen. See next:

Folding tablet with keyboard doesn’t prevent waking up

Yep, If I fold it up to carry with my I have to make sure I use a really untight grip, or the “mouse” buttons at the bottom of the keyboard gets pressed, sends an event, and wakes up the screen. My only workaround is to manually lock the screen before I fold it up. But that also forces me to use the screen lock which I really don’t want to – it’s in the way of me getting work done. This is the most annoying thing about this gizmo currently.

The main problem here is that the keyboard surpasses the screen lock completely. Simply press any button twice (first wake up, next to pass the screen lock) and you’re there.

Undocking from keyboard folio

This is very doable but requires two hands, some technique and a firm hand. It’s really not convenient and I rarely succeed to undock it in under 30 seconds. Not a big issue though – I don’t have the need to unplug this very often at all.

Ctrl key doesn’t work like as expected

Ctrl+arrow keys doesn’t move a word, and thus Ctrl+Shift+arrow doesn’t select a word. I expected this to work like on any OS cramped out after 1990’s (this was “standard” on my first computer ever, an Atari STE boosted with 1024 MB RAM). This is limiting but I can live with it.  (I bet you hitting Ctrl+4 in CKEditor won’t work either – changing the paragraph to a H4 headline, like in the wordpress blog editor. Actually, writing short blog entries would work but a longer one, like this one, is painfully slow.)

Headphone/microphone noise

There’s constant buzz and “static” noise when using the wire for sound. Terrible. Workaround – use bluetooth for sound (or HDMI, not for headset though). With a lot of activity going on (not sure if it’s wifi, internal/external storage or 3G) it gets worse. It’s like the background noise of a cellphone call. Terribly annoying.

Headphone/microphone jack layout is non-standard

I have many wired headsets with a microphone. None of them works in this socket – one channel is “zeroed” out – I guess microphone and either ground or one of left/right is swapped in some way. Terribly annoying. On my Sony Ericsson Arc phone, and the N900, I could plug in either a connector with three or four fields (left, right, ground, microphone).

The accompanying headset does work but is a really sheep one. And, why ship a headset with microphone when dialing is disabled? Makes little sense to me (Skype, basic note taking/recording, voice commands – sure).

Automatic adjustment of screen brightness is not good

It jumps up and down and takes really long to adjust when moving from a light room to a dark one. I control this manually and I’ve not really seen any device handle this very good. Best in class in my opinion is Apple’s Macbook Air.

Spotify and other newly launched processes suddenly dies

When the Spotify GUI is open, at random it is reaped (I think) to clear up RAM. This kills playback and I have to restart the app. Reaping processes/apps unfortunately happens way too often. Dolphin for Pad dies 1 time out of ten launches, approximately.

3G connectivity is much worse than on Sony Ericsson Arc

It works OK, is fully acceptable, but it’s also quite easy to see that it performs much worse (data transfer wise) than compared to my Sony Ericsson Arc. Not sure if the keyboard folio is part of explanation to this.

Browsers hidden from task list

In the list of tasks that is running none of Firefox, Dolphin and the android vanilla browser. Unless it was started from the Home screen – if it’s started from an Intent from inside any other application (such as e-mail, gmail, RSS) it’s not visible in the task list. Very strange but I also think this is an Android Honeycomb 3.1 feature/bug and has nothing to do this tablet specifically.

The firmware upgrade broke keyboard support

Had to do a firmware reset (after the upgrade) to get the Swedish keyboard layout back. This means re-install everything, re-enter all passwords (WHY can’t twitter, facebook, linkedIn etc allow each other’s OAuth?) in apps and each browser (WHY can’t the Android OS provide an authentication mechanism, like Mozilla’s suggestion), re-arrange the home screen (remove all the Lenovo-fluff). Business device level of “tested” – how could this slip through, really?

Bugs or misbehaviors

Yes, there are tons of minor bugs I don’t care to much about, but will list them anyway.

  • The Market app for Honeycomb is excellent and terrible. It makes good use of landscape mode, but that’s the only mode it runs in!
  • You can’t review apps from the Market app – you have to open a browser, find the app (there’s no “open in browser button”) and do it that out-of-app way.
  • I have bought some 10 apps to use on my phone. I’m not interested in having Talking Tom Cat on the tablet however, so I’ve chosen not to install that app. This unfortunately means that NO new apps will install just by clicking the Install button. Instead it queues up and sits in “My apps” list/view and waits for manually selecting it in that view and press Install again. It does charge my credit card right away though …
  • Can’t make phone calls. It simply lacks this feature. Not important but I kind of expected this to work since I’ve seen Galaxy Tab 7″ users use their pads (tablets) as a complete phone replacement. I really could do without my phone if the tablet had call support. SMS works perfectly.
  • Since phone calls aren’t supported there’s really no reason that the tablet announces a bluetooth SCO profile (phone headset – this is high priority, two way audio with lower latency and lower fidelity compared to A2DP which is high fidelity one way audio intended for video/music).
  • A2DP – or at least the play/pause, next and previous-buttons on my mostly brilliant Sony Ericsson MW600 bluetooth headset doesn’t work with the tablet. It’s otherwise working great and so far I’ve had no stability or sound quality issues at all. The folio keyboard has buttons media buttons that work really well so this is not a big issue for me. It’s just that I was surprised this doesn’t work.
  • Screen flashes before going to sleep. (Before it goes to sleep, the screen is dimmed on all android devices, but on this device it starts by going to full brightness and then down to something very low before coming to a short pause, then being turned off.)
  • TestApp – there’s an uninstallable app called TestApp that has all rights available, eats about 70 MB of RAM. Gives no clue to what it actuall does.
  • Home screen has one Android vanilla widget for gmail, one Android vanilla widget for my wendt.se IMAP account, one Android vanilla widget showing upcoming events from my (10) Google calendars, one GTasks widget showing one Google Task list, ~20 app icon/shortcuts, 3 contacts. This consumes > 100 MB of RAM. With all visible
  • The Lenovo ThinkPad logos on the leather keyboard folio is located on the wrong side. Not that it bothers me, but it’s a clue of how much effort they really spent on this product.
  • There should be two speakers, and none of them should be placed where you put your lap (make sure they’re on opposite sides of the device so you always something out of it, and NOT covered by the keyboard folio dock …)
  • A couple of times, the e-mail app got stuck in some data transfer/synchronization mode and I’ve had to actually reboot the device to get out of that state. Has happened more than twice.
  • Twice the device has rebooted spontaneously at the exact same location (at the Domkyrkan bus stop) when reading RSS on my way home. Connectivity issue lurking and a switch of GSM cells happens at this location?

Lenovo ThinkPad Tablet Product Image

Summary

This device certainly meets my initial functional requirements – I’m now on top of the constant stream of RSS feeds I want to keep up with and I’ve been writing e-mails much faster than ever before! So to that end, I’m very happy with this Lenovo ThinkPad Tablet. It also meets most secondary functions as well (spotify, calendar, …). However, there are some – or rather LOTS of – glitches that I didn’t expect to see in this rather expensive device. In total, it cost me about 600 € including the nice-looking leather keyboard folio and I really didn’t expect the “screen is activated from keyboard click when the ‘lid’ is closed” issue.  If the following issues were fixed, in order, I’d be perfectly happy:

  1. stop activating screen/wake up when it’s folded/lid is closed
  2. stop killing Spotify, Dolphin and reboot
  3. charge from any micro USB charger (doesn’t have to be full speed, but just take whatever you get and use it in whatever way you can)

Unimportant misc notes

  • I did consider getting a Transformer – but there’s no 3G on that and I don’t want to fiddle with wifi hotspot on my phone because that EATS battery and I don’t want to depend on two devices to read RSS
  • The backside coating/material on the ThinkPad Tablet is much nicer compared to the Ipads’ aluminumish slippery alternative
  • There might be some case+keyboard pack that would’ve worked well with the Ipad. I searched but didn’t find one. Nor did the ones I looked at for the Galaxy Tab really look like something I’d like to work with on the tram. Lenovo’s folio keyboard is a regular USB device (keyboard+pointer) and so does not contain a battery that needs charging/replacing after some time.

vilket_är_lättast_AttLäsaTyckerDu

Jag har skaffat mig en åsikt: det_är_lättare_att_läsa_vanlig_text_så_här, änAttLäsaDetNärDetStårSammanSkrivetUtanNågonWhiteSpace. De flesta känner till att vi mnäskionr kan lsäa ord unta srröte poerblm bara start- och slutbokstaven står på rätt plats. FrsöökGröaSmmaaSakMedDtetaTxbtelcok. Så, jag har skaffat mig åsikten att underscore är en bra idé att använda i t ex namn på test(metoder). I JavaScript brukar de flesta testramverk erbjuda följande mönster:

TestCase("Nu testar vi logiken i UserManager", {
    "lägga till en användare": function() {
        var before = this.userManger.getUserCount();
        this.userManager.addUser("Fredrik", "Wendt");
        var after = this.userManger.getUserCount();
        assertThat(after, equals(before + 1));
    }
});

Det är då ganska lätt att se vad som gått fel när en rapport säger:

In Suite "Nu testar vi logiken i UserManager", the test "lägga till en användare" failed.

I Java kan vi inte använda blanktecken som del av identifierare. I Java 7 kan man iaf använda 1_000_000 för att skriva ut en miljon, yay! Men det löser inte problemet med att få läsbara namn på test(metoderna). Understreck till räddning!

Ett problem som följer med understreck är att Eclipse rätt ur lådan inte stödjer att hoppa inom identifierare som innehåller just understreck: ctrl+höger hoppar alltså till slutet av hela identifieraren. Med AnyEditTools (finns på Eclipse Marketplace) blir detta problem ett minne blott, och man får också hjälp att konvertera mellan Camel Case och Underscores. Perfekt julklapp! :)

Fyra självklara friheter?

Jag uppgraderade precis WordPress till 3.3 och till min stora glädje lyder en av de tre stora flikarna på sidan efter lyckad installation “Freedom”.

WordPress is Free and open source software, built by a distributed community of mostly volunteer developers from around the world. WordPress comes with some awesome, worldview-changing rights courtesy of its license, the GPL.

  1. You have the freedom to run the program, for any purpose.
  2. You have access to the source code, the freedom to study how the program works, and the freedom to change it to make it do what you wish.
  3. You have the freedom to redistribute copies of the original program so you can help your neighbor.
  4. You have the freedom to distribute copies of your modified versions to others. By doing this you can give the whole community a chance to benefit from your changes.

Don’t you wish all software came with these freedoms? So do we! For more information, check out the Free Software Foundation.

WordPress logo badge

Typ-smocka med Mockito

Jag stötte på en riktig fuling idag när jag skulle skriva ett test likt det nedan. Hittade “lösningen” på mailinglistan efter att ha läst ett par buggar/feature requests.

Som jag förstår det går det inte att lösa pga Javas Type Inference i metodanrop. I exemplet nedan kan raden med when aldrig fungera utan man får gå på doReturn istället.

package demo;

import static java.util.Arrays.asList;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import java.util.Collection;

import org.junit.Test;

public class GenericCollectionStubTest {

    @Test
    public void onGoingStubFails() {
        Car bmw = mock(Car.class);
        Reseller reseller = mock(Reseller.class);
        Collection cars = asList(bmw);

        //when(reseller.getModels()).thenReturn(cars);

        doReturn(cars).when(reseller).getModels();
    }
}

Raden med when misslyckas med följande meddelande:

The method thenReturn(Collection<capture#1-of ? extends Vehicle>) in the type OngoingStubbing<Collection<capture#1-of ? extends Vehicle>> is not applicable for the arguments (Collection<capture#2-of ? extends Vehicle>)

PyDev: Pythonutvecklingsmiljö

PythonPyDev är baserad på Eclipse, funkar väldigt bra för det jag gör, vilket i princip är att försöka jobba på samma sätt med Python-kod som med Java (TDD-ish = få ut kod i jämnt flöde och refactor för att få det fint).

Vid dagens diskussioner kring tools och miljöer på GothPyCon ][ så gjorde jag följande anteckningar (“konferensen” hölls på engelska) över features jag förväntar mig i en IDE:

  • graphical, remote debugging
  • virtual environments
  • syntax highlighting
  • unit test integration with coverage
  • auto completion
  • indentation
  • inline documentation
  • refactoring
  • easy navigation

Allt detta – förutom debugging – demonstreras i en fem-minuters demo på PyDevs hemsida, ihop med de tangentbindningar som är “speciella” för PyDev:

Shift+Alt+n
Shift+Enter
Ctrl+2, r
Shift+Alt+a
Ctrl+F9
F12
Ctrl+F11
Ctrl+Alt+l
Shift+Ctrl+Alt+m
Ctrl+Alt+↓↑
Alt+↓↑
alt+→

Presentation om testdriven JavaScript-utveckling

Igår talade jag på JavaForum om tre verktyg (JsTestDriver, JsHamcrest, JsMockito) som möjliggör en godkänt komfortabel miljö för testdriven utveckling av JavaScript-kod. Jag har slangat upp presentationen på SlideShare och koden som det refereras till finns på GitHub.

Jag skulle kanske tryckt lite mer på att det i min mening inte lämpar sig för end-to-end-tester, typ ATDD eller BDD – där är fortfarande något som har Selenium i botten kung (om man gör det rätt).