There was a time when you could experience the web in only one way: on a computer. Today we know that’s no longer true. We have a plethora of devices that can connect to the web. Even our watches can get connected. Soon enough, with the Internet of Things, our toaster will serve us a toast with the most popular tweet of the day written on it. Web pages are no longer web pages but web applications. Therefore, we can’t build them the way we used to. With all these different devices consuming your application you’ll want to provide them with the best experience. Hence, you’ll have to adapt your web application, to not only fit in their smaller screens but to behave in the way their native applications do. If your application is not capable of adapting to these devices you’re missing quite a lot of potential customers. In fact, there are whole countries for which the majority of people experience the web only through a mobile phone or tablet. In order to make these applications adaptable we have to move out from traditional software web development strategies and gather a more modern approach.
So, how do you develop your web application so that it can handle all of these devices and the ones to come? Well, “the secret to building large apps is to never build large apps” (Justin Meyer). You build smaller components that can be managed and tested independently and used them as building blocks for your large software applications. And we’ve known this for years but is more apparent now with the uprise of the web and mobile market.
The first piece of our application starts in the server. The server is the brain of the application; it implements your business logic and manages the information that comes and goes from your database. Usually, it’s also responsible for formatting that data in a presentation language, such as HTML, before sending it back to the client. The problem here is that your client may not understand HTML, or may need to access just a portion of the data you sent. Reading those bits of data from an HTML document is hard and sometimes impossible. With native apps for mobile devices, if you want them to be connected in some way, your best option is to build a RESTful web service that exposes an API your application can call and get back something the app can read easily such as JSON or XML. With web applications you can do the very same thing. By removing the responsibility of the server to present your data you’re then free to consume that data in the mobile application, in a watch, or even on a toaster. The client will decide how to present and manipulate the data.
With both the client and server being completely decoupled you’ll have the flexibility required to compete in the fast moving world of technology. When a new device comes into play, such as that write-a-tweet-in-your-toast toaster, you just have to implement a new client for it. No need for touching the old code that runs your web application. When that new and faster framework comes out you can switch to it and your clients won’t have any problems. Your web application will be ready for the future.