How do they do it – the right way to write software
[Concrete / Interesting] Sitting at my desk and looking at the plans for the next scheduled release of our enterprise application and, oh boy, this looks like it’s gonna take forever. Not an unusual thought to pass through the mind of a development manager. But wait, does it really have to be this difficult? Is there a better way.
How do they do it?
On another subject, one of the guys in the team shows me Trello (www.trello.com) – 5 minutes in and it looks like the right tool for the job.
It’s a line of business application and it does what it says on the tin. Then my mind wanders and I find myself asking “how do these guys make any money? how do they write this stuff and sell it for nothing? how do they do it?”. So I dig a little deeper and the clue to how is to be found at the following URL:
Yes, behind the web client, iOS, Android and Windows 8 clients, there is a business level REST API. And take a look at the structure, API nouns based on key business entities like ‘board’ and ‘card’ with REST based verbs like GET / PUT / DELETE and where it makes sense, a search API.
What about the client?
Well looking more closely at the web client with web kit tools and Fiddler I discover how simple it is. The web client implements the user interface directly against the REST API. A very appealing UX is provided by jQuery and a few extension libraries like jquery-ui for UI widgets, drag & drop.
XHR – The final bit of the puzzle falls into place
But is the client really doing all the work or is there a server side? Well watching the page load I can see a bunch of XHR requests – that is XMLHttpRequests or AJAX. The first one gets the summary level details like a list of the boards, summary attributes and status and then there are further calls for board details and other board status. So there is no server side as you would find in an ASP.Net class of application, just the web service API supporting a client.
Putting it all together
So Trello and applications like it can be classed as API based client applications, whether it is a web client written in HTML, CSS and jQuery or mobile app written in mobile native (iOS, Android or similar). With these applications the following features seem to come up again and again:
1) REST API
Behind the app is a REST API with business specific APIs with entity based nouns and REST verbs. And typically the API provides one or more search 2.0 methods.
2) Fixed and limited scope to the app.
The app is typically limited to a single core concept – for Trello this is ‘Organize anything together’ or collaborative project management. Even if this is not the case after a few generations of the application, the early generations are typically single paged with singular business focus and a limited set of business entities.
3) Rich UI / UX
Being very focused and limited in terms of scope allows the developers to invest in a rich user interface and user experience.
Again, because of tight scope and especially because all the hard work is being done by the API, the developers can invest effort in native ports to multiple platforms like iOS and Android.
Testing the theory
Ok, so that all sounds easy enough. To get an app out fast I need to write an excellent but business focused REST API and chuck a rich user interface on top. To test the theory I put together a simple one page application for performing ‘Sentiment Analysis’ on twitter terms.
Sentiment Analysis simply tells you whether a population ‘likes’ or ‘hates’, ‘agrees’ or ‘disagrees’ with something. I built a Bayesian filter with corpora weighted for ‘like’ and ‘dislike’ based on a large number of Tweets. I then used this filter against a search of recent tweets matching a given search term. So for a term like ‘TFL’, 100 tweets are analysed as either positive or negative.
In this app, a simple web service is responsible for returning the resulting analysis for a given search term. You can see this API at:
For the client, I started with a template website from ThemeForest (www.themeforest.net). Lots of templates to choose from, many of them containing rich user interface component, HTML5 and responsive web designs.
Just add a little AJAX to an input field and voila – a single page application is born. Total development time – about 6 hours:
P.S Why’s it so slow
The site is slow but the development was really quick. The site and REST API are both hosted on a slow platform and would benefit from deployment to an enterprise platform. There are a bunch of improvements that can be performed server side and this is where performance improvements should be considered so that all the client benefit.
More can be done on the client, like some graphics to better illustrate the response from the search. But this is version 1. And remember, all done in less than a day.