Tuesday, 18 August 2015

Thoughts on Architecture and Software Design

To be honest and fair, these are not my thoughts but great principles I have learnt in my programming career. Its a unassorted list of references that I keep going back to, when discussing architectural concepts with development teams. Penning it here as my own reference.

Service Oriented Design

Services are the building blocks of architecture. They need to be simple, self contained and designed for re-use; right from the start. Application features expose their data and functionality through service interfaces. Services communicate with each other only through the interface over the network (Http / Messaging). No other communication allowed - binary dependency, direct data store access, shared memory model and all other backdoor access should be disallowed. All services should be designed to be externalizable.

Design Paradigms

API Driven - Abstraction is the key component of providing an integrated service offering. Applications needs to be built on top of a rich API which assists down the line with integration with downstream and upstream systems and implementations can be changed without impact.
Scalable - Applications should be decomposed into small, loosely coupled, stateless building blocks that can be scaled independently. Architecture should always bear cost in mind and allow business levers to scale both horizontally and vertically as necessary.
Adaptive - Dont make applications more complicated than they should ever be. Follow the KISS principle. Look for Apple product design guidelines as an inspiration to make things as intuitive as possible.
Resilient - Protecting your organization's / customer's data is the first priority for applications. Applications must be able to absorb individual failures and provide a seamless degradation of service based on availability. Don't treat failure as an exception but as an event of regular happening.
Secure - Integrating security into applications should be a ground-up activity and not an afterthought. Enterprise level of authentication, access-controls and data encryption should be applied from basic design.

Continuous Delivery

Principles vs Practices - Best practices are subjective and depend largely on context, while principles are eternal and universal. The delivery lifecycle should be based on fundamental 'agile manifesto' rather than beating around on specific development practices. - http://simpleprogrammer.com/2013/02/17/principles-are-timeless-best-practices-are-fads/
Continuous business value vs Time-boxed iterations - The delivery should be based on providing continuous business value in the form of small functional releases rather than arbitrary time boxes. - http://kief.com/iterations-considered-harmful.html
Measurements and analytics - You really have to treat the software development process more like a relationship than like a factory. Instead of focussing on measurements and metrics, the emphasis should be given to trends and variance of the development lifecycle. - http://simpleprogrammer.com/2013/02/11/we-cant-measure-anything-in-software-development/
Philosophy on Estimations - The key is that you first accept that making accurate long-term estimates is fundamentally impossible. - http://blog.hut8labs.com/coding-fast-and-slow.html

Thursday, 15 January 2015

Simple Conferencing with Twilio, BlockSpring and AWS

Recently an entrepreneur friend of mine complained that plain teleconferencing services are expensive and in certain business situations, it is not possible to use social applications like Skype or Google Hangouts. To quantify it, he said an hour call between 4 people in the US and UK cost around ~ GBP 15 or around $23 at professional providers like GotoMeeting or Powwownow. Having known about Twilio and the power of Cloud, I felt this was not right and set about to write a simple conferencing facility POC for him which turned to be a huge cost saver. Interestingly a TollFree number costs about $2 per month and a local number about 1$, that comes to around 4$ per month recurring or admin cost as he decided to have a TollFree and Local number in the US and just a local number in the UK. A similar conference for 4 people now only costed $2.5 per hour and it was super efficient, also when we added a web based calling to it, the cost flattened around a dollar or less.

One of the salient features of the POC was that I decided not to build any backend application and use BlockSpring one of the recent discoveries for me to build a function that can allow to integrate Twilio. And use only Amazon AWS S3 to host a static web page which is a client-side Javascript application as the end point. This post simply details the steps and the code that was used to build the POC and make it open to anyone who would like to try on their own.

1. Create a static website using Amazon S3

You can refer to the official guide or follow this simple tutorial to create a static website on Amazon S3. Also you can setup a custom domain name like simple-conference.mydomain.com if that is something you'd prefer.

2. Register two applications with Twilio

Sign-up for a new account at Twilio if you already did not have one and do spend sometime looking at the self-explanatory guides and documentation which are very useful. For the conferencing app, we will create two application end-points, one to act as an administrator account which would begin and end the conference and the second one adds users as participants to the call.

NOTE: Please remember that we are using Amazon S3 to host our TwiML end-points, so the request URL must have the "HTTP GET" method, otherwise you'd have exceptions.

3. Add the following code end-points to S3 website

4. Create an account at BlockSpring

BlockSpring allows developers to create, run and share functions across multiple server side languages including PHP, Python, NodeJs, Ruby, R etc. Though the following function is open-source and can be called from your application, you will still need to register an account and get an API Key of your own to connect to the function. 

5. Use the Twilio Token Generator Function from BlockSpring

You can use my public open-source function hosted at "https://api.blockspring.com/vshank77/82c3cb17747dcc677ab5816969962f91".

Since at the time of this writing, there is no integration between Github GIST and BlockSpring or way to embed a BlockSpring function, I have elaborated the source code of the Twilio.

6. Create the Javascript App and add it your S3 website

Please note that the account ID / Application ID in the following code are hard-coded to test accounts and will not work. You will need to use your own Twilio Account ID and Begin/Join App_ID when you upload this code.

7. Optionally associate calling numbers to the Twilio Function

If you also need to connect to the application from regular phone number, buy as many numbers as you want and point them to the "Simple Conference Join" TwiML function. The only caveat is that since we don't have any backend service of our own, you can create administrator functions on the phone and will have to use web site to begin the conference.

That's it; You now have a fully functioning conference at a very low cost.

Friday, 30 November 2012

Hard reverting a Maven release with Git

When trying to release a maven project, Git automatically tags your repository and then updates the project to a new version. However if there are any failures in between, the release cannot be fully undone and needs manual intervention to clean up the state.

The following code snippet shows how you can fully revert your project by removing both the tags and resetting the previous commit.