Saturday, August 2, 2014

Building Web Services Quickly

Haven't We Been Here Before?
Seattle from the harbour.

The last time I built a web service was back in 2009. I figured out Google App Engine (GAE), it was great since it used Python (my pet language at the time) and with free hosting at the level I was going to use it, that was the platform for me.

I built Hockey Tweet with GAE and then designed Tweety10, a Cocoaheads Ottawa app, which a team of 6 built in 3 weeks in 2010 for the 2010 Olympics to use GAE as well. I ramped up one of the guys on GAE and he built out our web service while I worked on whatever needed my help.

What's This Web Service For?

I have a team that is interested in hiring me, possibly on contract, for their app. They would like a portfolio to see what I have done; which is hard to show when you work for large companies. So I am building a demo app, that will have a web service backend. As such I need to build a web service to simulate some of the features they mentioned. So I am cooking up a web service to simulate the backend service they want to build. I figure this is a good portfolio piece.

You see, I have worked for many teams/companies but those have been larger teams that had many people building the end-to-end solution. For this, I need to show I can build the app end-to-end. They are looking for their own on-site web services programmer but I need something to build my app against for the demo.

I also want some experience with technologies/framework/APIs I have not used yet. There are a lot of frameworks and APIs available to use in modern mobile apps and as such it is hard to find time to learn stuff you don't need for your day to day job. So, I want to try out some stuff I would need for this project, if the team decide to go with me, and also that will help me improve my portfolio to show that I can build an app from scratch with various technologies to meet a clients needs.

Tonight I laid out the storyboards for the app based on the initial use cases the team told me about. The storyboards let me get an idea of what data I will need to support the app. With that in mind I can also think about what the API calls should be. I see the storyboards as a visual walkthrough of the user stories, a kind of overview of the apps back-end.

Deciding on the Web Service Framework

I did some research an evening or two ago on various web frameworks so I could figure out what to mockup the backend web service in. I decided on sinatra, which is built on ruby. It is an alternative to Ruby on Rails and instead of following a Model-View-Controller design it is geared towards quickly developing a web application. So in other words, throw good design to the wind and hack up that web service fast. Perfect.

With Sinatra, you get the basics, but there are some additional features I want which were easy to add. I have added the following gems:
  • gem install sinatra
    • Basic sinatra framework
  • gem install sinatra-authentication
    • Adds authentication framework for your apps. I want to simulate adding users, login, logout, and then mapping users to resources (i.e. events for a user)
  • gem install sinatra-jsonp
    • To add json data payloads.
  • gem install shotgun
With that I have a basic web service running that I can talk to.

Next I will start to build up the API and write tests to hit the web service. I will then start to fill in the app by populating the UI with the data I am pushing from the web service.

I could skip the web service and do this with dummy data in the app but I want some current experience building a web service and so I am approaching the demo app this way.

No comments: