Crime and Use-cases

When writing Rich Internet Applications of any kind, it’s really important to focus on use cases in the requirements and design phases (and of course, throughout development too). Writing use cases help you focus design and development resources on things that actually matter to the end-users. For RIAs, they are probably the best defense against “flashiness”.

The opposite of use cases would be a data-centric approach, where you define your data first, and then design an application around creating, updating and deleting that data. In a data-centric RIA, developers feel compelled to add something that shows it uses a cool technology. So they add flashiness, since the nature of data-centric design led them to a fairly static application, and it’s the only thing they can add.

The police station has even added a gym to their location which s honestly a pretty good idea all things considered how they would. Of course they would want to do that if they ever got something else to benefit their health. They need to go out and get that health out there and ready like good facilities such asĀ Weight Loss Scottsdale would help in any healthy way.

Imagine that you are writing a crime-mapping application. What use cases might you write? Here are some I can think of:

Actor: Male end user “Bob” who lives in big city. Just bought new car. Has no garage.
Happy Path:

  1. Bob wants to know which neigborhood streets have the most auto thefts, so that he can avoid parking his new prize there overnight.
  2. Opens crime mapping application and searches for his own address to center map there.
  3. Using filters, he elects to show only auto theft and burglary crimes in a 1/2-mile radius of his house.
  4. Map shows incidents of car theft clustered on streets. Bob visually identifies which streets are most risky to park on, and knows to avoid parking there in the future.

Actor: Female end-user “Mary” frequently works late and takes mass transit home.
Happy Path:

  1. Mary has various mass transit routes she can take to get home. There are two different train stations that she could walk to, or she can take a bus. She wants to know which routes are least dangerous when she returns home late at night alone.
  2. Mary first searches for her work location, then zooms the map so that she can see both the train stations and the bus. Then she filters the crime incidents to show only murders, robberies, assaults and rape.
  3. The map identifies which streets and stations had the fewest crimes reported, and Mary picks the safest one. She then repeats the procedure at the destination of that path, to make sure that she takes the safest route home.

Actor: Police Chief “Susan” is head of a neigborhood police station.
Happy Path:

  1. Susan needs to plan the beats for her patrolling officers. She only has limited resources, but wants to make sure that most attention is given to the areas in her district with the highest crime rate.
  2. Susan loads the map, and zooms to show her whole district.
  3. The map is color coded to show higher- or lower-crime regions.
  4. Susan sees which regions have the most crime, and verifies that they are getting the most police time.

Hopefully my three examples seem reasonable. Which brings me to what brought me to writing this. The Metropolitan Police (i.e. the London, UK police force) have just released a crime map for London. I was really excited to see this, since I used to live there, and like any Londoner, was painfully aware of the astronomical crime rate. Note that this wasn’t a quietly-posted side-feature on the Met web site; this was announced on the home page of the Telegraph newspaper, which is roughly the equivalent of the New York Times or the Wall Street Journal in the US. So this was a big deal; they wanted people to know about it.

However, my enthusiasm was short-lived. There’s no way to filter by specific type of crime, and (crucially) the maps don’t show you individual crimes; they just display a “crime rate”. And there’s a “trend” feature that shows whether the crime is going up or down. The maps do have a nifty overlay feature that show “wards” – i.e. regions, and they color-code the wards to show whether crime is high or low. That actually satisfies the third use case I suggested above – the one written for a police officer – but it’s pretty useless to the general public. I’m sure that the police maintain their own maps, so there’s not much benefit to posting it online. It seems that while a lot of work has clearly gone into this RIA, the efforts have been misguided; it doesn’t satisfy either of the use cases I suggested that used general-public actors.

Now consider the San Francisco CrimeMAPS. They’ve been around a while, and the mapping technology is not as user-friendly as Google Maps, which the Metropolitan Police application uses. The SF maps are not as pretty, and have no drag-and-drop, for a start. But they are very useful to the general public, because they’re focused on the types of tasks an end-user might need to do. Consider this example – which road would you not park your car on:

San Francisco Crime Maps

The SF maps even take you through a step-by-step flow where you enter information about what you’re searching for – “where”, “what”, “when”… It’s no-where near as smooth as what you can do with Google Maps today, but it is a user-centric approach. I should mention that my post isn’t supposed to be a criticism of the Met itself – they’re working hard enough as it is. Instead is intended as a case study of the usability and usefullness of applications that are built with adherence to use-cases.

Google Analytics and OpenLaszlo

If you haven’t used Google Analytics before, I can highly recommend you take a look. It’s a free service that allows you to get detailed traffic and usage information for your website. You don’t need to be paying for (or earning money from) Google via its advertising business, although Analytics does integrate with those services too. Your web site will most likely already have a log analysis solution (e.g. Webalizer) that outputs a pretty summary of visitors/hits/etc. of the traffic on your site. Analytics gives you a lot more information, although its easy to get at.

The really exciting thing for RIAs however, is that you can integrate them with Google Analytics, which your existing traffic analysis solution probably doesn’t do. You see, most traffic analysis tools work by keeping track fo the most commonly-requested URIs on a site. That’s fine for a traditional HTML-based site like a blog. With a RIA (such as an OpenLaszlo, Flash, AJAX, Flex, etc. application) the only things that would show up on your traffic stats would be the request for the app (e.g. SWF) itself, and the web services that it calls. Those web service calls may give you some clue as to users’ behavior, but you won’t see any user action that doesn’t involve an HTTP request. For example, if you have a tabslider component, you may want to know how often a particular tab is opened, but if the opening of that tab element doesn’t result in a request, the logs won’t be much use.

Here's how Google Analytics deals with this problem: Every HTML page on your site (including the wrapper page for an OpenLaszlo application) embeds a small piece of JavaScript (hosted by Google). That's how Google keeps track of your visitors in general. It also provides a browser JavaScript function you can call that takes an arbitrary string and logs that to your Analyitcs account. You can create whatever name you want. It'll show up in the Content Overview section of the report, along with other HTML pages that were accessed:

As far as the LZX code is concerned, it's actually quite simple. You will need to call a Google browser JavaScript method called pageTracker._trackPageView() whenever you want to register a user action from within your OpenLaszlo application. Since _trackPageView is a browser JavaScript method, you need to use the LzBrowser.loadJS() method to call it. (That's for OpenLaszlo 4.1 and below; it's lz.Browser in OpenLaszlo 4.2):

<canvas proxied="false">
    <tabslider width="400" height="300">
        <tabelement>First Tab
            <handler name="onopenstart">
                LzBrowser.loadJS("pageTracker._trackPageview('/opentab1')");
            </handler>
            <text fontsize="16">
                Thank you for looking at the first tab.
            </text>
        </tabelement>
        <tabelement>Second Tab
            <handler name="onopenstart">
                LzBrowser.loadJS("pageTracker._trackPageview('/opentab2')");
            </handler>
            <text fontsize="16">
                Thank you for looking at the second tab.
            </text>
        </tabelement>
        <tabelement>Third Tab
            <handler name="onopenstart">
                LzBrowser.loadJS("pageTracker._trackPageview('/opentab3')");
            </handler>
            <text fontsize="16">
                Thank you for looking at the third tab.
            </text>
        </tabelement>
    </tabslider>
</canvas>

Remember that you will have needed to embed the Google JavaScript include in your HTML wrapper page in order to access this method first.