Strava versus Garmin Connect for tracking cycle rides

I love my Garmin Edge 500 GPS cycle computer. It tracks pretty much every piece of data I would want (I don’t have a power meter though) to know how I’m doing on my rides. Up to now I’ve used the Garmin Connect site to upload ride activity for viewing and analysis.

Connect is very good, and whilst lots of people seem to complain about it, I’ve always found it fine in terms of performance and stability. There are a few things that I find annoying: I don’t like that they moved to Bing Maps, they just don’t work as well as Google and there’s no terrain view. I also wish they would show an indicator on the map when you hover over a point on the various graphs (e.g. to see where exactly the elevation occurred on the map) and finally I wish they would show some form of gradient information. Connect does however do a good job of displaying and making accessible all of the data that the Edge captures.

The sharing capabilities are basic on Garmin Connect. The Facebook sharing is pretty poor as it just displays a Connect logo on the news post. The Twitter integration is also poor with no ride details in the default message being posted. Finally, blog integration is via an iframe widget which doesn’t work in WordPress. There is an OK third party plugin which I’ve used here (and which in the latest version allows you to use Google Maps!)

Recently however I’ve been looking at a site called Strava. I’d seen it referenced on BikeRadar and other forums, mainly as it has a nifty feature which extracts hills and other segments from the rides people submit and tracks performances and generates leader boards.

However, as a pure Garmin Connect alternative, Strava seems very useful. It uploads from my Edge 500 directly, uses GMaps, includes gradient info, links the maps and graphs and what’s more it is entirely HTML with no Flash (another pet hate about Garmin Connect)

There are a couple more features in Strava, including a power estimation (which should probably be taken with a large pinch of salt) and a “suffer score” which rates your rides according to how tough they were based on your HR zones.

The social aspects of Strava are also much stronger than Garmin Connect. Whilst you can find other people and rides on Connect, it always seems like an afterthought only provided through a search interface. In Strava you can follow other riders, view their profile, give them “kudos” for a particular ride and also find clubs in your area. Clubs themselves can establish a presence on the site. It feels much more like a cycling social network.

Finally, Strava is much better at sharing your ride data outside. It integrates to Facebook and Twitter via Connect and OAuth well and default messages are better than Connect (e.g. on Twitter it includes the ride distance) There are nice widgets for including information on blogs, though again they rely on iframes which WordPress will strip out of blog posts. Thankfully I found an excellent plugin which solves that (see the previous post for examples of it in use) The plugin makes use of the Strava JSON API (Garmin also have an API) and I make a small tweak to it to display distance/speed in miles/miles per hour. Finally, it has some good privacy options including the ability to obfuscate certain locations on maps. For instance if you start/finish rides at your home you can tell Strava where that is and it will truncate routes to make it less obvious.

There are some niggles. Firstly, and most importantly, to use all of it’s capabilities requires you to pay a subscription ($60 per year) which I have done. However they recently lifted the 5 ride upload per month limit for non paying users which makes the site much more useful if you don’t want to pay. I also find that navigation could be better, the search doesn’t deal with non US locations too well (e.g. defaults are not local to me) and there could be more contextual help available. Finally it is difficult to bootstrap your network of people. Options to import friends from Facebook/Twitter would be good.

All in all however I’ve already found it better to use and much cleaner and fresher than Garmin Connect. Given the difficulties that a lot of people seem to have with Connect right now, and their bungled updates recently, then maybe Strava will be the winner.

Training update – 1 Aug to 7th Aug

As a way of tracking my training leading up to and beyond the Ride Around London (see JustGiving sponsorship widget on the right, hint hint…) I’m going to write a weekly update summary.

The last week saw me head out for one evening ride after work. I clocked up twenty miles and found a couple of nice short steep hills quite nearby. I Got a bit lost in Harpenden though and inadvertently headed back towards Wheathampstead.

On Saturday I headed out with a friend, Paul. We’d arranged to meet in Potters Bar as he was coming from North London. I got a bit lost on the way and ended up in South Mimms Services, but once sorted we did about 25 miles up to Hertford and back through some lovely countryside. I’d always aimed for this to be a relatively relaxed ride but at times the pace was quite high anyway. With the to and from St. Albans added in this was a useful 45 miles.

The next day I once again headed out with my new cycling club on a Sunday Run. I joined the Intermediates again and we headed out towards Leighton Buzzard, over the Dunstable Downs. There were a couple of nice climbs but in general this was an easier ride than the week before. I felt good however, especially considering I’d been out the previous day. The cake stop was nice but the journey back saw the rain start falling for the last 15 miles or so and nobody had come prepared. There were one or two hairy moments on descents and corners but we all got back no problem. One person did puncture, so I spent some time that afternoon practicing changes so that if it happens to me I won’t hold people up too long.

In summary, I’ve managed 120 miles at 15-16mph average over the week, which I think bodes pretty well at this stage. I now need to start increasing the length of one of the rides each week to build up to the point where I can comfortably do 80-90 miles in one go.

VCC Sunday ride

As mentioned before, I’m targeting a 115 mile charity ride at the end of September. Up until now, my training has been infrequent. To combat this I finally decided to bite the bullet and join the Verulam Cycling Club. Today I headed out on their weekly Sunday club ride. At 9am there were about 50 people at the top of St. Albans high street and a lot of expensive machinery on show. I joined the “intermediates” group which is meant to average about 16mph. This is slightly more than I’d typically manage on my own, but the theory was that I could always drop back to the “sociables” group who would be on the same route. There were a couple of other newbies in the group as well.

The plan was to head for a tea stop in Westmill then head back, meaning a round trip of 55-60 miles. As we headed out of St. Albans towards Wheathampstead I concentrated on getting used to the mechanics of group riding, as well as chatting to whoever was next to me as we rode two abreast. I’ve nearly always ridden solo, but once I’d sussed out the rules and etiquette of an organized group I found the miles simply flew by. You use less energy when sheltered in the slipstream of the person in front and therefore the average speed of a group is typically higher than solo riding. This leaves you with more energy when it comes to the uphill stuff and I found myself pushing up the hills more than I usually would, even overtaking some of the group. When riding solo you spend so much energy pushing through the wind all the time that hills just become morale sapping.

After about 28 miles we hit the tea stop, and a very nice one it was too! A Lemon Drizzle cake, coffee and bottle fill up hit the spot nicely.

The ride back was fun with some short climbs and some nice fast sections. I peeled off as we got to Sandridge as my parents were coming over, so I missed the final 5 miles or so.

All in all it was a very enjoyable ride, and I’ll be aiming to become a regular. It has also made me sure that I’ll want to get into a group on the Ride Around London. Up to now on sportives I’ve suffered through on my own, failing to put in the effort to latch on when groups have come past.

Verulam CC Ride for a Reason

On Sunday I took part in the Verulam Cycling Club Ride for a Reason cycling event in St. Albans. This is organized to coincide with National Bike Week and is the fifth year it has been run. Obviously it is the first year I’ve taken part given we’ve only been living here for two months.

On Friday I’d still not decided whether or not to do the 44 mile route, or attempt the tougher 64 mile version. The latter is not much shorter than the longest ride I’ve ever done. However after signing up for the Ride Around London I figured the longer route would give me a good benchmark of where I was and how much training I’m going to need to plan for before September rolls around.

Turnout was pretty good (I think about 130 people in all) and at 8am when I started pretty much everybody was doing to longest route. The weather, even at that time was very warm, and it was only going to get warmer as the morning went on. For the first 30 miles I felt great and, whilst riding on my own the majority of the time managed an average speed of about 16mph over some undulating terrain (but with no real hills) I felt strong in my legs and powered up most of the bumps I came across. I probably spent more time in the big ring than I’ve done before, holding about 20mph on the flat

However, then the sun really started to take effect and whilst I was drinking lots and taking the odd gel, I did feel my energy levels falling. This, combined with the much hiller second half of the ride slowed me down a lot. At 40 miles I hit the main challenge of the hill coming from Charlton into Preston. Whilst short, it is consistently steep with my Garmin reporting about a 17% gradient in places. Climbing remains my weakest point and I had to stop a couple of times just for a few seconds to let me heart rate go down a bit.

After that was a welcome checkpoint (all three of which were excellently run and given the low entry price of £7 very well stocked!) The run after the checkpoint then involved a few more short but not so sharp hills. I rolled home in 4 hours 17.5 minutes of moving time, averaging 14.9mph. Further gory details from my Garmin are here.

I was certainly impressed with the running of the event, and plan to attend one of the next Verulam CC Sunday runs before probably joining up. All in all this event told me that I’ve got a lot of work to do to make the 115 mile event in September enjoyable and not a long slog! At least the sun should not be so strong. Finally, lesson of the day is to remember to apply sunblock. I’ve got wicked pro-style tan lines!

London 2012 tickets once more.

A short postscript to my previous posts on my attempt to land tickets for London 2012.

I got official confirmation that of the 14 sessions I applied for (mostly track cycling and swimming – things I really, really wanted to see some of) I was allocated four tickets to a Women’s Basketball session on the first full day of competition.

It appears I made a fatal mistake in my strategy. Whilst concentrating my initial application on the stuff I really wanted, and potentially committing a significant amount of money, I also put in a few filler sessions here and there. For instance, the women’s basketball falls between morning and evening swimming sessions that I’d applied for. The thinking was obvious – we’d be on the Olympic site all day so why not maximise the opportunity to see things.

However, this decision backfired in a big way.

After the initial storm of protest over the handling of the initial ticket ballot, LOCOG announced plans for a second round of sales in late June/July. Crucially, first preference for this round would go to people who got NOTHING from their initial application. Now, whilst there was no swimming or track cycling available in the second round, there were still some fairly choice sessions, including some athletics in the main stadium. The key difference to the second round compared to the first was that it was first-come first-served.

Hence, when tickets went on sale last week the most attractive events went in minutes (not withstanding the rather bizarre problems in people actually knowing if their order was actually successful.)

The key point for me was that if you were at all successful in the first ballot, as I was, then you have to wait until 17th July to take part in the second round. By that time, it is likely all that will be left is football tickets, primarily in places like Hampden Park, Scotland.

So, by choosing some filler material in my initial application I’ve effectively handicapped myself from having a second bite of the cherry. I’m happy for friends who have been tweeting about the athletics tickets they’ve had confirmation of over the weekend, and just to reiterate, I’m happy I’ll be seeing something of the games, especially in the Olympic Park. However, had I known how the full process was going to work before I made any application whatsoever, I’d have done things differently. I’d have gone only for the stuff I really, really wanted in the first round and been happy to fight for whatever was left at the first opportunity if I was unsuccessful in the first round.

Sadly, I doubt I’ll ever get the chance to put that into practice.

Ride Around London 2011

I’ve not blogged much about cycling on here (if at all) but it has been a sport I’ve been interested in and have followed for most of my life. Last year I became a fully fledged MAMIL (well, maybe not yet middle-aged) and bought a road bike. I did a couple of events in Ireland last autumn (the Wicklow 100 and the Leinster Loop) and spent many happy hours in the saddle in the Dublin and Wicklow mountains building up my fitness.

However since the turn of the year and our move back to the UK I’ve not been on the bike so much. I’ve only clocked up a total of 130 miles in 2011 so far according to my Garmin. Fourty of those were in one event at the St. Albans Charity Cycle ride, and another thirty on a weekend ride to visit my parents recently. I do ride my hybrid bike to and from the train station most days, but that is just a four mile round trip.

However, all that is about to change as I am going to ramp up my cycling. To provide motivation I’ve signed up for the 2011 Ride Around London in September. This is a 115 mile event, which means it will be my first century ride and about 40 miles further than I’ve ridden in one day. It also takes in a fair few hills including Box Hill (which the pros will be tackling numerous times on the London 2012 Olympic road races) and a stint through the Chiltern Hills.

Ride Around London route

The event is being held in support of Access Sport, a charity that aims to provide more access to local sport to children, especially in deprived areas. To that end, I’ve set up a Just Giving page on which you can sponsor me.

I’m going to blog more about my cycling here to keep track of my progress. To begin with I’m planning to enter the Verulam CC’s Ride For a Reason event this Sunday though I’ve not decided on whether I’ll do the 44 mile or 64 mile route yet.

London 2012 Olympics ticket result

I’d previously blogged about my London 2012 ticket application. In brief, I applied for a fairly large number of sessions, focussed around track cycling as well as some swimming, one athletics session, a few other assorted choices and the opening ceremony. In total the application came to between £2,300 to just under £3k as I applied for a range of session prices (and in most cases did not go for the cheapest tickets)

Well, I now know the result. I’ve got tickets.

olympictx.jpg

Taking away the £6 admin fee, I’ve received £140 worth of tickets. it is clear that the only thing or combination of sessions I applied for that comes to that amount is four tickets to the Women’s Basketball on Saturday 28th July at £35 each.

Now, I am fully aware that lots and lots of people (including lots of friends) got nothing. It’s going to be amazing to be on the olympic site on the first day of full competition.

However, I also know I am not alone in being very disappointed that of the outlay I was willing to spend I’ve ended up with less than 6% of it, and only then because it is an early session in a very low demand sport that will certainly have plenty of tickets available in the second chance phase later this month.

I certainly did not hope for everything, but I longed for one of the track cycling sessions. I deliberately made applications for single tickets at the second highest price bracket for the midweek evening sessions as well as applications for nearly every other track session. I know the venue only seats 6000 people, but to get nothing is disappointing.

I do know, and understand, why the process worked like it did. On the flip-side I agree with a number of people I’ve seen argue about the imperfect information provided about the number of tickets at various price categories etc. Having moved back to the UK from Ireland recently, and started a new job, there has been some stress involved in making sure I had the funds available to cover my potential outlay for these tickets whilst juggling moving costs, rent deposits and other large outgoings before I’d even picked up my first pay packet. I would have been delighted to get everything I asked for – everything was there for a reason as the original blog post makes clear. However part of me wonders how many people played the game of making outrageous applications on the bet that their actual allocation would be of a reasonable value and worst-case if they “got” everything then their payment would be declined. In hindsight it seems that this type of gaming was the only way to improve your odds of succeeding from the system.

I’ll be applying for the track cycling preparation event which happens in February 2012 as well as taking a look at the Paralympic events. It must not be forgotten that there are truly awesome athletes that take part in the Paralympic Games. Track cycling itself can point to Sarah Storey who afterall is good enough to force her way into the able-bodied GB track team.

A tale of two commutes

I’ve been commuting into London daily now for a month. Enough time to get a good feel for it. We were in the lucky position of being able to locate ourselves somewhere where the commute is about as good as it can get without being in London itself, so here’s my typical day:

0725 – Leave home and cycle the two miles to St Albans City station

0744 – Get the semi-fast Thameslink train to London Blackfriars. There is a fast train (straight to St. Pancras then onwards) at the same time which is always standing room only. The one I get takes a whole eight minutes longer to get to Blackfriars than the fast one and I get a seat every morning. The only time I didn’t was when the fast one was canceled one morning.

0824 – Arrive at Blackfriars and walk along Queen Victoria Street, over the Millennium Bridge and along Bankside to the FT at One Southwark Bridge

0835 – Arrive at my desk.

1715 – Leave work and walk back to Blackfriars

1736 – Get the fast train back. Always get a seat

1806 – Arrive at St Albans, cycle back home

1815 – Get back home.

This will improve even more in December when the Bankside entrance to Blackfriars opens, which will at least halve the amount of time I walk to/from work.

So far I’ve hardly been affected by delays or cancellations. I have come close though when I narrowly avoided the chaos caused by a power failure at Kentish Town the other week. All in all I’m very happy with how things have gone so far and have no regrets about the commute (or anything else about the job!)

This was driven home today when I went to a one-day event at the Hilton Park Lane. This meant adding an underground journey into the commute. I purposely looked to avoid any tube journeys in my daily commute and today proved why. The trip into town in the morning was fine. I got the same train I’d normally get, got off at St. Pancras and then took the Piccadilly Line to Hyde Park Corner. Coming back however I left at 5, stood on a packed and hot tube for 15 minutes, then boarded the same train I normally get home, but from St. Pancras, not Blackfriars. By St. Pancras however the train is packed and I stood the twenty minutes back to St. Albans. So, the time was about the same, but the hassle increased and comfort decreased.

I’ve probably jinxed it all now.

Week One

I’ve now been in my new job a full week. So far so good. Here’s some rough thoughts:

  • The commute is better than expected. I typically get the 0744 train from St. Albans to Blackfriars and after that it is a 10-15 minute walk. This will get even better in December when the Bankside entrance to Blackfriars opens. Coming home I normally get the 1736 back. The total commute is about an hour each way.
  • I get a seat both ways, every day.
  • The weather has been fantastic making the walk delightful. No rain so far!
  • The new team are great. Nice bunch of people. I’m the second dev on the team, and we had a third join this week.
  • Theres a lot of contractors. Something new to me.
  • I’m working on the project that allows journalists/editors to apply various metadata to articles that then serves many purposes, including what sections of ft.com the article appears in.
  • So far I’ve got my development environment set up, pair programmed my first defect fix, and also delivered my first solo fix and done a bit of code refactoring along the way.
  • There’s some meaty new feature work planned for the next couple of months that should keep us busy.
  • It’s completely and utterly different to the experience of IBM product development teams in many ways, which requires a blog post of it’s own.
  • I’ve not been on a single conference call. Our customers are one floor down (in the newsroom, which I got to visit on the first day)
  • We have a product owner and in general the scrum roles are much more clearly defined than on any project I’ve ever worked on.
  • Have yet to eat lunch in the work canteen. I’ve always gone out for lunch, normally with others. There’s lots of choice around and prices are not as bad as I thought they would be.
  • Free tea/coffee saves me a lot of money anyway.
  • Today I didn’t even bring my laptop home.

Unit testing in Scala

This post is copied over from my internal blog inside IBM, just for posterity after I’ve left. It was first published in March 2011.

In my Baby Steps in Scala blog post I introduced the group sync problem I used to experiment with Scala as a language. After spending a bit more time learning the language features and syntax I switched focus to start looking at the ecosystem around it, including tooling and frameworks.

In my early experiments I simply used the Eclipse Scala plugin with straightforward project structures. The plugin is pretty basic and prone to crashes. The good news however is that Martin Odersky himself has been working on improving it.

As a strong believer in test-driven development I wanted to explore the ways that Scala code can be tested. I’d already managed to write Junit tests for the group sync example that called the Scala code, but I wanted to look more at specific frameworks for Scala testing. I also wanted to understand how Scala code can be integrated into a build environment.

I’ll cover the testing aspect in this post, and build in another.

A quick Google search showed there are three common testing frameworks around Scala:

The interesting thing is that the focus of all of them is not just “how can I test Scala code” but more on how the capabilities of the Scala language itself can be harnessed to produce tests which are much more natural and easy to define and understand. This is primarily done through Scala’s excellent support for DSLs.

All three frameworks are also more than just Unit test libraries and execution environments. They advocate specification and behaviour driven testing.

I didn’t spend much time investigating each, but based on material I’d read I chose Specs to play around with. Specs itself can make use of ScalaCheck anyway. Specs encourages up-front specification of test cases or behaviour in a very human readable form. For instance, here is the initial specification I wrote for my group sync service:

package com.adrianspender.groupsync.scala.test

import org.specs._

class GroupSyncSpecification extends Specification {

  "group sync service" should {
    "remove any cached groups if the user is no longer in any groups" in {}

    "not change the cache if the groups for the user have not changed" in {}

    "add groups to the cache if the user has been added to new groups " +
      "so that the cache matches the groups" in {}

    "remove groups from the cache if the user has been removed from groups " +
      "so that the cache matches the groups" in {}

    "update the cache when the user has been added to new groups and " +
      "removed from old ones so that the cache matches the groups" in {}
  }
}

As you can see, the specifications are written in natural language that could easily be taken from the acceptance criteria of a story I’m working on. In true TDD/BDD fashion this can be written before any coding takes place. It can also be executed to produce the following output (in this case it is being run through sbt, but I’ll cover that in the entry on building)


(click the images to view full size)

The suite contains one test, known as a group (“group sync service” should) which then defines a set of examples such as “remove any cached groups if the user is no longer in any groups”.

We then expand the examples by specifying expectations, which is really the meat of our test and what would go inside a Junit test method. To take the first example, we need to test that if the user is not in any groups, then the cache should be emptied for them. You can look back at the Baby Steps in Scala post for the actual code we are testing.

At this point, if I was implementing this test in Junit, I’d start thinking about the collaborations that the class I am testing has, and how I can provide mock implementations of them with the behaviour I need. In this case I need:

  • A mock AuthoritativeSource which will return an empty set for the given user
  • A mock PersistentCache on which we need to assert that the removeAllGroups() method gets called

In Java I use the EasyMock library to provide a way to define mock objects with the behaviour I want, and to validate the runtime behaviour is as expected. Specs provides support for using EasyMock (and Mockito) within Specs and all you need to do is change your Specification to add the EasyMock trait:

package com.adrianspender.groupsync.scala.test

import org.specs._
import org.specs.mock.EasyMock
import org.easymock.EasyMock._

class GroupSyncSpecification extends Specification with EasyMock {
  ...
}

This then provides us with a Scala-friendly abstraction over the EasyMock library. We can now define our mock objects, set their expected behaviour, replay them and verify them (if you are unfamiliar with EasyMock, take a look at the tutorial here) With this in place, I am now ready to implement the expectations of the specification:

"remove any cached groups if the user is no longer in any groups" in {
      val authoritativeSource = strictMock[AuthoritativeSource]
      val persistentCache = strictMock[PersistentCache]

      val groups = new java.util.HashSet[String]()
      val personId = "1234"

      authoritativeSource.getGroups(personId) returns groups
      persistentCache.removeAllGroups(personId)

      replay(authoritativeSource, persistentCache)

      val groupSyncService = new GroupSyncServiceImpl(authoritativeSource, persistentCache)
      groupSyncService.syncGroups(personId)

      verify(authoritativeSource, persistentCache)
    }

Stepping through the code we are doing the following:

  1. Creating our mock objects for AuthoritativeSource and PersistentCache
  2. Creating an empty set for AuthoritativeSource to return and defining the userid we will use
  3. Setting the behaviour of our mocks:
    • We expect the getGroups() method of AuthoritativeSource to be called with personId, and we want it to return the empty group set.
    • We then expect the removeAllGroups(personId) method to be called on PersistentCache
  4. We replay both mock objects, so that EasyMock understands what should happen
  5. We create an instance of our GroupSyncServiceImpl – the class we are testing. The collaborators are injected through constructor injection
  6. We call groupSyncService.syncGroups(personId)
  7. We ask EasyMock to verify that the behaviour we expected actually happened.

And that is one part of our specification test implemented. We can then run it again:

You can see that the test we implemented is passing. We could break the test, for instance by doing this:

      val groups = new java.util.HashSet[String]()
      groups.add("group1")

So that now the group set returned from the AuthoritativeSource is not empty. Running this produces:

Here we expected one invocation of removeAllGroups() but there were none.

Let’s fix that and implement the rest of the examples. We then have a passing set of specification tests:

Finally, we have a working set of tests, but for integration into an existing Build/Continuous Integration environment, or even within Eclipse we may want to be able to execute them as JUnit tests. We can do this simply by changing the trait we use to the SpecificationWithJunit trait and annotating the class as such:

package com.adrianspender.groupsync.scala.test

import org.specs._
import org.specs.mock.EasyMock
import org.easymock.EasyMock._
import org.specs.runner.JUnitSuiteRunner
import org.junit.runner.RunWith

@RunWith(classOf[JUnitSuiteRunner])
class GroupSyncSpecification extends SpecificationWithJUnit with EasyMock {
  ...
}

Then we can simply run the whole thing as a Junit test in Eclipse:

So, Specs is a really easy way to write human readable specifications and their implementations. What’s more, it can integrate with Junit and therefore existing CI/reporting mechanisms and existing testing libraries such as EasyMock.

However, what is perhaps most impressive is that all this ease of use and power can be applied to you Java code as much as any Scala code you have. There is nothing at all to stop you using Specs, or any Scala test framework, to test Java code. This is why testing is such a great vector for starting out with Scala and building skills. You can start to introduce it into an existing Java project orthogonally through your tests rather than diving straight into writing production code in Scala.